Hi,
I'm currently playing with http async (trunk version) and websockets and I
noticed that In the handshake phase, when the server responds with
101 Switching Protocols, the platform hangs waiting for a response:
Future<HttpResponse> future = httpclient.execute(request, null);
HttpResponse response = future.get();
I located this problem in the and I modified this
class NHttpClientProtocolHandler to treat only the "100 Continue" response in
the 1xx category as it is now, leaving the default processing (as for 200) for
101 and 102. I hope this patch below helps :
Index: main/java/org/apache/http/impl/nio/client/NHttpClientProtocolHandler.java
===================================================================
---
main/java/org/apache/http/impl/nio/client/NHttpClientProtocolHandler.java(revision
1142906)
+++
main/java/org/apache/http/impl/nio/client/NHttpClientProtocolHandler.java(working
copy)
@@ -248,18 +248,18 @@
HttpResponse response = conn.getHttpResponse();
HttpRequest request = httpexchange.getRequest();
- int statusCode = response.getStatusLine().getStatusCode();
- if (statusCode < HttpStatus.SC_OK) {
- // 1xx intermediate response
- if (statusCode == HttpStatus.SC_CONTINUE
- && httpexchange.getRequestState() == MessageState.ACK)
{
- int timeout = httpexchange.getTimeout();
- conn.setSocketTimeout(timeout);
- conn.requestOutput();
- httpexchange.setRequestState(MessageState.BODY_STREAM);
- }
- return;
- } else {
+int statusCode = response.getStatusLine().getStatusCode();
+
+// 1xx intermediate response
+if (statusCode == HttpStatus.SC_CONTINUE
+&& httpexchange.getRequestState() == MessageState.ACK) {
+int timeout = httpexchange.getTimeout();
+conn.setSocketTimeout(timeout);
+conn.requestOutput();
+httpexchange.setRequestState(MessageState.BODY_STREAM);
+return;
+
+} else {
httpexchange.setResponse(response);
if (httpexchange.getRequestState() == MessageState.ACK) {
int timeout = httpexchange.getTimeout();