Permalink
Browse files

TYRUS-263: SSL via HTTP Proxy.

  • Loading branch information...
1 parent 7e3dd29 commit 3652c5a01844c64e2145152956a38c9c4a03f709 @pavelbucek pavelbucek committed Oct 31, 2013
@@ -236,28 +236,6 @@ public NextAction handleRead(FilterChainContext ctx) throws IOException {
// client
if (tyrusConnection != null) {
- final HttpStatus httpStatus = ((HttpResponsePacket) message.getHttpHeader()).getHttpStatus();
-
- if (httpStatus != HttpStatus.SWITCHING_PROTOCOLS_101) {
- if (proxy) {
- if (httpStatus == HttpStatus.OK_200) {
-
- // TYRUS-221: Proxy handshake is complete, we need to enable SSL layer for secure ("wss")
- // connections now.
- if (sslFilter != null) {
- ((GrizzlyClientSocket.FilterWrapper) sslFilter).enable();
- }
-
- ctx.write(getHttpContent(webSocketRequest));
- } else {
- throw new HandshakeException(String.format("Proxy error. %s: %s", httpStatus.getStatusCode(),
- new String(httpStatus.getReasonPhraseBytes(), "UTF-8")));
- }
-
- return ctx.getInvokeAction();
- }
- }
-
// this is websocket with completed handshake
if (message.getContent().hasRemaining()) {
@@ -276,6 +254,29 @@ public NextAction handleRead(FilterChainContext ctx) throws IOException {
// tyrusConnection == null
+ // proxy
+ final HttpStatus httpStatus = ((HttpResponsePacket) message.getHttpHeader()).getHttpStatus();
+
+ if (httpStatus.getStatusCode() != 101) {
+ if (proxy) {
+ if (httpStatus == HttpStatus.OK_200) {
+
+ // TYRUS-221: Proxy handshake is complete, we need to enable SSL layer for secure ("wss")
+ // connections now.
+ if (sslFilter != null) {
+ ((GrizzlyClientSocket.FilterWrapper) sslFilter).enable();
+ }
+
+ ctx.write(getHttpContent(webSocketRequest));
+ } else {
+ throw new HandshakeException(String.format("Proxy error. %s: %s", httpStatus.getStatusCode(),
+ new String(httpStatus.getReasonPhraseBytes(), "UTF-8")));
+ }
+
+ return ctx.getInvokeAction();
+ }
+ }
+
// If websocket is null - it means either non-websocket Connection
if (!UpgradeRequest.WEBSOCKET.equalsIgnoreCase(header.getUpgrade()) && message.getHttpHeader().isRequest()) {
// if it's not a websocket connection - pass the processing to the next filter

1 comment on commit 3652c5a

Please sign in to comment.