Top Description Fields Constructors Methods
io.netty.handler.codec.spdy

public Class SpdyHttpEncoder

extends MessageToMessageEncoder<HttpObject>
Class Inheritance
Imports
io.netty.channel.ChannelHandlerContext, io.netty.handler.codec.MessageToMessageEncoder, .UnsupportedMessageTypeException, io.netty.handler.codec.http.FullHttpMessage, .HttpContent, .HttpHeaderNames, .HttpHeaders, .HttpMessage, .HttpObject, .HttpRequest, .HttpResponse, .LastHttpContent, io.netty.util.AsciiString, io.netty.util.internal.ObjectUtil, java.util.Iterator, .List, .Map, .Map.Entry

Encodes HttpRequests, HttpResponses, and HttpContents into SpdySynStreamFrames and SpdySynReplyFrames.

Request Annotations

SPDY specific headers must be added to HttpRequests:
Header NameHeader 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 to HttpResponses:
Header NameHeader 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 pushed HttpRequests:
Header NameHeader 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 all HttpContents 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.

Field Summary

Modifier and TypeField and Description
private int
private final boolean
private final boolean

Constructor Summary

AccessConstructor and Description
public
SpdyHttpEncoder(SpdyVersion
the protocol version
version
)

Creates a new instance.

public
SpdyHttpEncoder(SpdyVersion
the protocol version
version
,
boolean
convert header names to lowercase. In a controlled environment, one can disable the conversion.
headersToLowerCase
,
boolean
validate the header names and values when adding them to the SpdyHeaders
validateHeaders
)

Creates a new instance.

Method Summary

Modifier and TypeMethod and Description
private SpdyHeadersFrame
private SpdySynStreamFrame
protected void
encode(ChannelHandlerContext ctx, HttpObject
the message to encode to an other one
msg
,
List<Object>
the List into which the encoded msg should be added needs to do some kind of aggregation
out
)

Implements abstract io.netty.handler.codec.MessageToMessageEncoder.encode.

Encode from one message to an other.
private static boolean

Returns:

whether the given HTTP message should generate a last SPDY frame.
isLast
(HttpMessage
check this HTTP message
httpMessage
)

Checks if the given HTTP message should be considered as a last SPDY frame.

Inherited from io.netty.handler.codec.MessageToMessageEncoder:
acceptOutboundMessagewrite

Field Detail

currentStreamIdback to summary
private int currentStreamId
headersToLowerCaseback to summary
private final boolean headersToLowerCase
validateHeadersback to summary
private final boolean validateHeaders

Constructor Detail

SpdyHttpEncoderback to summary
public SpdyHttpEncoder(SpdyVersion version)

Creates a new instance.

Parameters
version:SpdyVersion

the protocol version

SpdyHttpEncoderback to summary
public SpdyHttpEncoder(SpdyVersion version, boolean headersToLowerCase, boolean validateHeaders)

Creates a new instance.

Parameters
version:SpdyVersion

the protocol version

headersToLowerCase:boolean

convert header names to lowercase. In a controlled environment, one can disable the conversion.

validateHeaders:boolean

validate the header names and values when adding them to the SpdyHeaders

Method Detail

createHeadersFrameback to summary
private SpdyHeadersFrame createHeadersFrame(HttpResponse httpResponse) throws Exception
Annotations
@SuppressWarnings:deprecation
createSynStreamFrameback to summary
private SpdySynStreamFrame createSynStreamFrame(HttpRequest httpRequest) throws Exception
Annotations
@SuppressWarnings:deprecation
encodeback to summary
protected void encode(ChannelHandlerContext ctx, HttpObject msg, List<Object> out) throws Exception

Implements abstract io.netty.handler.codec.MessageToMessageEncoder.encode.

Doc from io.netty.handler.codec.MessageToMessageEncoder.encode.

Encode from one message to an other. This method will be called for each written message that can be handled by this encoder.

Parameters
ctx:ChannelHandlerContext

the ChannelHandlerContext which this MessageToMessageEncoder belongs to

msg:HttpObject

the message to encode to an other one

out:List<Object>

the List into which the encoded msg should be added needs to do some kind of aggregation

Annotations
@Override
Exceptions
Exception:
is thrown if an error occurs
isLastback to summary
private static boolean isLast(HttpMessage httpMessage)

Checks if the given HTTP message should be considered as a last SPDY frame.

Parameters
httpMessage:HttpMessage

check this HTTP message

Returns:boolean

whether the given HTTP message should generate a last SPDY frame.