Remove WebSocketHttpResponseDecoder hack.
This commit is contained in:
parent
7dbd97d702
commit
c0b86cd6c0
@ -84,7 +84,7 @@ public class WebSocketClient {
|
||||
HashMap<String, String> customHeaders = new HashMap<String, String>();
|
||||
customHeaders.put("MyHeader", "MyValue");
|
||||
|
||||
// Connect with V13 (RFC 6455). You can change it to V08 or V00.
|
||||
// Connect with V13 (RFC 6455 aka HyBi-17). You can change it to V08 or V00.
|
||||
// If you change it to V00, ping is not supported and remember to change
|
||||
// HttpResponseDecoder to WebSocketHttpResponseDecoder in the pipeline.
|
||||
final WebSocketClientHandshaker handshaker =
|
||||
@ -95,11 +95,7 @@ public class WebSocketClient {
|
||||
public ChannelPipeline getPipeline() throws Exception {
|
||||
ChannelPipeline pipeline = Channels.pipeline();
|
||||
|
||||
// If you wish to support HyBi V00, you need to use
|
||||
// WebSocketHttpResponseDecoder instead for
|
||||
// HttpResponseDecoder.
|
||||
pipeline.addLast("decoder", new HttpResponseDecoder());
|
||||
|
||||
pipeline.addLast("encoder", new HttpRequestEncoder());
|
||||
pipeline.addLast("ws-handler", new WebSocketClientHandler(handshaker));
|
||||
return pipeline;
|
||||
|
@ -1,51 +0,0 @@
|
||||
/*
|
||||
* Copyright 2011 The Netty Project
|
||||
*
|
||||
* The Netty Project licenses this file to you under the Apache License,
|
||||
* version 2.0 (the "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jboss.netty.example.http.websocketx.client;
|
||||
|
||||
import org.jboss.netty.handler.codec.http.HttpMessage;
|
||||
import org.jboss.netty.handler.codec.http.HttpResponse;
|
||||
import org.jboss.netty.handler.codec.http.HttpResponseDecoder;
|
||||
|
||||
/**
|
||||
* Fix bug in standard HttpResponseDecoder for web socket clients. When status 101 is received for Hybi00, there are 16
|
||||
* bytes of contents expected
|
||||
*/
|
||||
public class WebSocketHttpResponseDecoder extends HttpResponseDecoder {
|
||||
|
||||
@Override
|
||||
protected boolean isContentAlwaysEmpty(HttpMessage msg) {
|
||||
if (msg instanceof HttpResponse) {
|
||||
HttpResponse res = (HttpResponse) msg;
|
||||
int code = res.getStatus().getCode();
|
||||
|
||||
// FIX force reading of protocol upgrade challenge data into the content buffer
|
||||
if (code == 101) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (code < 200) {
|
||||
return true;
|
||||
}
|
||||
switch (code) {
|
||||
case 204:
|
||||
case 205:
|
||||
case 304:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user