notify handshake listener after request headers are set
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
parent
c6ec9fb4d2
commit
79a017d3ba
|
@ -327,6 +327,10 @@ public class HttpTransportOverHTTP2 implements HttpTransport
|
|||
// Only now that we have switched the attachment,
|
||||
// we can demand DATA frames to process them.
|
||||
stream.demand(1);
|
||||
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Upgrading to {}", connection);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -197,7 +197,6 @@ public abstract class ClientUpgradeRequest extends HttpRequest implements Respon
|
|||
throw new IllegalArgumentException("FrameHandler could not be created", t);
|
||||
}
|
||||
|
||||
initWebSocketHeaders();
|
||||
super.send(listener);
|
||||
}
|
||||
|
||||
|
@ -295,7 +294,7 @@ public abstract class ClientUpgradeRequest extends HttpRequest implements Respon
|
|||
|
||||
public abstract FrameHandler getFrameHandler();
|
||||
|
||||
private void initWebSocketHeaders()
|
||||
void requestComplete()
|
||||
{
|
||||
notifyUpgradeListeners((listener) -> listener.onHandshakeRequest(this));
|
||||
}
|
||||
|
|
|
@ -51,12 +51,16 @@ public class HttpUpgraderOverHTTP implements HttpUpgrader
|
|||
request.header(HttpHeader.UPGRADE, "websocket");
|
||||
request.header(HttpHeader.CONNECTION, "Upgrade");
|
||||
request.header(HttpHeader.SEC_WEBSOCKET_KEY, generateRandomKey());
|
||||
|
||||
// Per the hybi list: Add no-cache headers to avoid compatibility issue.
|
||||
// There are some proxies that rewrite "Connection: upgrade" to
|
||||
// "Connection: close" in the response if a request doesn't contain
|
||||
// these headers.
|
||||
request.header(HttpHeader.PRAGMA, "no-cache");
|
||||
request.header(HttpHeader.CACHE_CONTROL, "no-cache");
|
||||
|
||||
// Notify the UpgradeListeners now the headers are set.
|
||||
clientUpgradeRequest.requestComplete();
|
||||
}
|
||||
|
||||
private String generateRandomKey()
|
||||
|
|
|
@ -41,6 +41,9 @@ public class HttpUpgraderOverHTTP2 implements HttpUpgrader
|
|||
request.method(HttpMethod.CONNECT);
|
||||
request.upgradeProtocol("websocket");
|
||||
request.header(HttpHeader.SEC_WEBSOCKET_VERSION, WebSocketConstants.SPEC_VERSION_STRING);
|
||||
|
||||
// Notify the UpgradeListeners now the headers are set.
|
||||
clientUpgradeRequest.requestComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue