Merge pull request #226 from veebs/Issue222Part2
Issue #222 part 2 - Removed unnecessary websocket code and retested with Autobahn v0.4.10.
This commit is contained in:
commit
c061ddbf14
@ -26,13 +26,14 @@
|
||||
*
|
||||
* <p>03. Intall Python Setup Tools: <tt>sudo apt-get install python-setuptools</tt>
|
||||
*
|
||||
* <p>04. Install AutoBahn: <tt>sudo easy_install Autobahn</tt>
|
||||
* <p>04. Install AutoBahn: <tt>sudo easy_install Autobahn</tt>. If you already have Autobahn installed, you may need
|
||||
* to upgrade it: <tt>sudo easy_install --upgrade Autobahn</tt>. Make suer v0.4.10 is installed.
|
||||
*
|
||||
* <p>05. Get AutoBahn testsuite source code: <tt>git clone git@github.com:oberstet/Autobahn.git</tt>
|
||||
* <p>05. Get AutoBahn testsuite source code: <tt>git clone git@github.com:tavendo/AutobahnPython.git</tt>
|
||||
*
|
||||
* <p>06. Go to AutoBahn directory: <tt>cd Autobahn</tt>
|
||||
* <p>06. Go to AutoBahn directory: <tt>cd AutobahnPython</tt>
|
||||
*
|
||||
* <p>07. Checkout stable version: <tt>git checkout v0.4.3</tt>
|
||||
* <p>07. Checkout stable version: <tt>git checkout v0.4.10</tt>
|
||||
*
|
||||
* <p>08. Go to test suite directory: <tt>cd testsuite/websockets</tt>
|
||||
*
|
||||
@ -47,11 +48,12 @@
|
||||
* }
|
||||
* </code>
|
||||
*
|
||||
* <p>10. Run <tt>AutobahnServer</tt> in this package
|
||||
* <p>10. Run our <tt>AutobahnServer</tt> located in this package. If you are in Eclipse IDE, right click on
|
||||
* <tt>AutobahnServer.java</tt> and select Run As > Java Application.
|
||||
*
|
||||
* <p>11. Run the test <tt>python fuzzing_client.py</tt>. Note that the actual test case python code is
|
||||
* located in <tt>/usr/local/lib/python2.6/dist-packages/autobahn-0.4.3-py2.6.egg/autobahn/cases</tt>
|
||||
* and not in the checked out git repository.
|
||||
* <p>11. Run the Autobahn test <tt>python fuzzing_client.py</tt>. Note that the actual test case python code is
|
||||
* located with the easy_install package (e.g. in <tt>/usr/local/lib/python2.7/dist-packages/
|
||||
* autobahn-0.4.10-py2.7.egg/autobahn/cases</tt>) and not in the checked out git repository.
|
||||
*
|
||||
* <p>12. See the results in <tt>reports/servers/index.html</tt>
|
||||
*/
|
||||
|
@ -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 =
|
||||
@ -94,12 +94,7 @@ public class WebSocketClient {
|
||||
bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
|
||||
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 io.netty.example.http.websocketx.client;
|
||||
|
||||
import io.netty.handler.codec.http.HttpMessage;
|
||||
import io.netty.handler.codec.http.HttpResponse;
|
||||
import io.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;
|
||||
}
|
||||
}
|
@ -37,6 +37,7 @@ import io.netty.channel.socket.nio.NioServerSocketChannelFactory;
|
||||
* <li>Chrome 14+ (draft-ietf-hybi-thewebsocketprotocol-10)
|
||||
* <li>Chrome 16+ (RFC 6455 aka draft-ietf-hybi-thewebsocketprotocol-17)
|
||||
* <li>Firefox 7+ (draft-ietf-hybi-thewebsocketprotocol-10)
|
||||
* <li>Firefox 11+ (RFC 6455 aka draft-ietf-hybi-thewebsocketprotocol-17)
|
||||
* </ul>
|
||||
*/
|
||||
public class WebSocketServer {
|
||||
|
Loading…
Reference in New Issue
Block a user