Merge pull request #229 from veebs/3.2

Issue #222 part 2 for 3.x branch - Removed unnecessary websocket code and retested with Autobahn v0.4.10.
This commit is contained in:
Norman Maurer 2012-03-12 05:28:03 -07:00
commit 192fbe0572
5 changed files with 25 additions and 64 deletions

13
pom.xml
View File

@ -229,6 +229,19 @@
<ignore />
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<versionRange>[2.8,)</versionRange>
<goals>
<goal>check</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>

View File

@ -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>11. 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>
*/

View File

@ -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;

View File

@ -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;
}
}

View File

@ -37,6 +37,7 @@ import org.jboss.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 {