Package io.netty.handler.codec.spdy
Class SpdyHttpEncoder
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelOutboundHandlerAdapter
io.netty.handler.codec.MessageToMessageEncoder<HttpObject>
io.netty.handler.codec.spdy.SpdyHttpEncoder
- All Implemented Interfaces:
ChannelHandler
,ChannelOutboundHandler
Encodes
HttpRequest
s, HttpResponse
s, and HttpContent
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 pushedHttpRequest
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. |
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 allHttpContent
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 classes/interfaces inherited from interface io.netty.channel.ChannelHandler
ChannelHandler.Sharable
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate int
private final boolean
private final boolean
-
Constructor Summary
ConstructorsConstructorDescriptionSpdyHttpEncoder
(SpdyVersion version) Creates a new instance.SpdyHttpEncoder
(SpdyVersion version, boolean headersToLowerCase, boolean validateHeaders) Creates a new instance. -
Method Summary
Modifier and TypeMethodDescriptionprivate SpdyHeadersFrame
createHeadersFrame
(HttpResponse httpResponse) private SpdySynStreamFrame
createSynStreamFrame
(HttpRequest httpRequest) protected void
encode
(ChannelHandlerContext ctx, HttpObject msg, List<Object> out) Encode from one message to an other.private static boolean
isLast
(HttpMessage httpMessage) Checks if the given HTTP message should be considered as a last SPDY frame.Methods inherited from class io.netty.handler.codec.MessageToMessageEncoder
acceptOutboundMessage, write
Methods inherited from class io.netty.channel.ChannelOutboundHandlerAdapter
bind, close, connect, deregister, disconnect, flush, read
Methods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, exceptionCaught, handlerAdded, handlerRemoved, isSharable
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.netty.channel.ChannelHandler
exceptionCaught, handlerAdded, handlerRemoved
-
Field Details
-
currentStreamId
private int currentStreamId -
validateHeaders
private final boolean validateHeaders -
headersToLowerCase
private final boolean headersToLowerCase
-
-
Constructor Details
-
SpdyHttpEncoder
Creates a new instance.- Parameters:
version
- the protocol version
-
SpdyHttpEncoder
Creates a new instance.- Parameters:
version
- the protocol versionheadersToLowerCase
- convert header names to lowercase. In a controlled environment, one can disable the conversion.validateHeaders
- validate the header names and values when adding them to theSpdyHeaders
-
-
Method Details
-
encode
Description copied from class:MessageToMessageEncoder
Encode from one message to an other. This method will be called for each written message that can be handled by this encoder.- Specified by:
encode
in classMessageToMessageEncoder<HttpObject>
- Parameters:
ctx
- theChannelHandlerContext
which thisMessageToMessageEncoder
belongs tomsg
- the message to encode to an other oneout
- theList
into which the encoded msg should be added needs to do some kind of aggregation- Throws:
Exception
- is thrown if an error occurs
-
createSynStreamFrame
- Throws:
Exception
-
createHeadersFrame
- Throws:
Exception
-
isLast
Checks if the given HTTP message should be considered as a last SPDY frame.- Parameters:
httpMessage
- check this HTTP message- Returns:
- whether the given HTTP message should generate a last SPDY frame.
-