}
@SuppressWarnings("deprecation")
private SpdySynStreamFrame createSynStreamFrame(HttpMessage httpMessage) throws Exception {
// Get the Stream-ID, Associated-To-Stream-ID, Priority, URL, and scheme from the headers
final HttpHeaders httpHeaders = httpMessage.headers();
int streamID = httpHeaders.getInt(Names.STREAM_ID);
int associatedToStreamId = httpHeaders.getInt(Names.ASSOCIATED_TO_STREAM_ID, 0);
byte priority = (byte) httpHeaders.getInt(Names.PRIORITY, 0);
String URL = httpHeaders.get(Names.URL);
String scheme = httpHeaders.get(Names.SCHEME);
httpHeaders.remove(Names.STREAM_ID);
httpHeaders.remove(Names.ASSOCIATED_TO_STREAM_ID);
httpHeaders.remove(Names.PRIORITY);
httpHeaders.remove(Names.URL);
httpHeaders.remove(Names.SCHEME);
// The Connection, Keep-Alive, Proxy-Connection, and Transfer-Encoding
// headers are not valid and MUST not be sent.
httpHeaders.remove(HttpHeaders.Names.CONNECTION);
httpHeaders.remove(HttpHeaders.Names.KEEP_ALIVE);
httpHeaders.remove(HttpHeaders.Names.PROXY_CONNECTION);
httpHeaders.remove(HttpHeaders.Names.TRANSFER_ENCODING);
SpdySynStreamFrame spdySynStreamFrame =
new DefaultSpdySynStreamFrame(streamID, associatedToStreamId, priority);
// Unfold the first line of the message into name/value pairs
SpdyHeaders frameHeaders = spdySynStreamFrame.headers();
if (httpMessage instanceof FullHttpRequest) {
HttpRequest httpRequest = (HttpRequest) httpMessage;
frameHeaders.set(METHOD, httpRequest.method());
frameHeaders.set(PATH, httpRequest.uri());
frameHeaders.set(VERSION, httpMessage.protocolVersion());
}
if (httpMessage instanceof HttpResponse) {
HttpResponse httpResponse = (HttpResponse) httpMessage;
frameHeaders.set(STATUS, httpResponse.status());
frameHeaders.set(PATH, URL);
frameHeaders.set(VERSION, httpMessage.protocolVersion());
spdySynStreamFrame.setUnidirectional(true);
}
// Replace the HTTP host header with the SPDY host header
if (spdyVersion >= 3) {
CharSequence host = httpHeaders.getUnconverted(HttpHeaders.Names.HOST);
httpHeaders.remove(HttpHeaders.Names.HOST);
frameHeaders.set(HOST, host);
}
// Set the SPDY scheme header
if (scheme == null) {