Class SpdyHttpEncoder
java.lang.Object
org.jboss.netty.handler.codec.spdy.SpdyHttpEncoder
- All Implemented Interfaces:
ChannelDownstreamHandler
,ChannelHandler
Encodes
HttpRequest
s, HttpResponse
s, and HttpChunk
s
into SpdySynStreamFrame
s and SpdySynReplyFrame
s.
Request Annotations
SPDY specific headers must be added toHttpRequest
s:
Header Name | Header Value |
---|---|
"X-SPDY-Stream-ID" |
The Stream-ID for this request. Stream-IDs must be odd, positive integers, and must increase monotonically. |
"X-SPDY-Priority" |
The priority value for this request. The priority should be between 0 and 7 inclusive. 0 represents the highest priority and 7 represents the lowest. This header is optional and defaults to 0. |
Response Annotations
SPDY specific headers must be added toHttpResponse
s:
Header Name | Header Value |
---|---|
"X-SPDY-Stream-ID" |
The Stream-ID of the request corresponding to this response. |
Pushed Resource Annotations
SPDY specific headers must be added to pushedHttpResponse
s:
Header Name | Header Value |
---|---|
"X-SPDY-Stream-ID" |
The Stream-ID for this resource. Stream-IDs must be even, positive integers, and must increase monotonically. |
"X-SPDY-Associated-To-Stream-ID" |
The Stream-ID of the request that initiated this pushed resource. |
"X-SPDY-Priority" |
The priority value for this resource. The priority should be between 0 and 7 inclusive. 0 represents the highest priority and 7 represents the lowest. This header is optional and defaults to 0. |
"X-SPDY-URL" |
The absolute path for the resource being pushed. |
Required Annotations
SPDY requires that all Requests and Pushed Resources contain an HTTP "Host" header.Optional Annotations
Requests and Pushed Resources must contain a SPDY scheme header. This can be set via the"X-SPDY-Scheme"
header but otherwise
defaults to "https" as that is the most common SPDY deployment.
Chunked Content
This encoder associates allHttpChunk
s that it receives
with the most recently received 'chunked' HttpRequest
or HttpResponse
.
Pushed Resources
All pushed resources should be sent before sending the response that corresponds to the initial request.-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface org.jboss.netty.channel.ChannelHandler
ChannelHandler.Sharable
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate SpdyDataFrame[]
createSpdyDataFrames
(int streamId, ChannelBuffer content) private SpdySynReplyFrame
createSynReplyFrame
(HttpResponse httpResponse) private SpdySynStreamFrame
createSynStreamFrame
(HttpMessage httpMessage) private static ChannelFuture
getDataFuture
(ChannelHandlerContext ctx, ChannelFuture future, SpdyDataFrame[] spdyDataFrames, SocketAddress remoteAddress) private ChannelFuture
getMessageFuture
(ChannelHandlerContext ctx, MessageEvent e, int streamId, HttpMessage httpMessage) void
Handles the specified downstream event.protected void
writeChunk
(ChannelHandlerContext ctx, ChannelFuture future, int streamId, HttpChunk chunk, SocketAddress remoteAddress) Writes an HTTP chunk downstream as one or more SPDY frames.
-
Field Details
-
spdyVersion
private final int spdyVersion -
currentStreamId
private volatile int currentStreamId
-
-
Constructor Details
-
SpdyHttpEncoder
Creates a new instance.- Parameters:
spdyVersion
- the protocol version
-
-
Method Details
-
handleDownstream
Description copied from interface:ChannelDownstreamHandler
Handles the specified downstream event.- Specified by:
handleDownstream
in interfaceChannelDownstreamHandler
- Parameters:
ctx
- the context object for this handlerevt
- the downstream event to process or intercept- Throws:
Exception
-
writeChunk
protected void writeChunk(ChannelHandlerContext ctx, ChannelFuture future, int streamId, HttpChunk chunk, SocketAddress remoteAddress) Writes an HTTP chunk downstream as one or more SPDY frames. -
getMessageFuture
private ChannelFuture getMessageFuture(ChannelHandlerContext ctx, MessageEvent e, int streamId, HttpMessage httpMessage) -
getDataFuture
private static ChannelFuture getDataFuture(ChannelHandlerContext ctx, ChannelFuture future, SpdyDataFrame[] spdyDataFrames, SocketAddress remoteAddress) -
createSynStreamFrame
- Throws:
Exception
-
createSynReplyFrame
- Throws:
Exception
-
createSpdyDataFrames
-