From 7027fe66d7e0993871cf90915de87adaf87c9558 Mon Sep 17 00:00:00 2001 From: "Adrian T. Co" Date: Sat, 4 Mar 2006 01:32:44 +0000 Subject: [PATCH] Initial fix for http. Its still failing for some other reasons though (sync problems I think). git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@382998 13f79535-47bb-0310-9956-ffa450edef68 --- .../transport/http/HttpTransportFactory.java | 8 +++---- .../transport/http/HttpTunnelServlet.java | 24 ++++++++++++++----- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/activemq-optional/src/main/java/org/apache/activemq/transport/http/HttpTransportFactory.java b/activemq-optional/src/main/java/org/apache/activemq/transport/http/HttpTransportFactory.java index 850ca0bd62..c0bafaaa72 100755 --- a/activemq-optional/src/main/java/org/apache/activemq/transport/http/HttpTransportFactory.java +++ b/activemq-optional/src/main/java/org/apache/activemq/transport/http/HttpTransportFactory.java @@ -17,8 +17,6 @@ package org.apache.activemq.transport.http; import org.activeio.command.WireFormat; -import org.apache.activemq.transport.MutexTransport; -import org.apache.activemq.transport.ResponseCorrelator; import org.apache.activemq.transport.Transport; import org.apache.activemq.transport.TransportFactory; import org.apache.activemq.transport.TransportServer; @@ -45,7 +43,7 @@ public class HttpTransportFactory extends TransportFactory { if (wireFormat instanceof TextWireFormat) { return (TextWireFormat) wireFormat; } - log.trace("Not created with a TextWireFromat: " + wireFormat); + log.trace("Not created with a TextWireFormat: " + wireFormat); return new XStreamWireFormat(); } @@ -57,8 +55,8 @@ public class HttpTransportFactory extends TransportFactory { TextWireFormat textWireFormat = asTextWireFormat(wf); Transport transport = new HttpClientTransport(textWireFormat, location); //Transport transport = new HttpTransport(textWireFormat, location); - transport = new MutexTransport(transport); - transport = new ResponseCorrelator(transport); + //transport = new MutexTransport(transport); + //transport = new ResponseCorrelator(transport); return transport; } diff --git a/activemq-optional/src/main/java/org/apache/activemq/transport/http/HttpTunnelServlet.java b/activemq-optional/src/main/java/org/apache/activemq/transport/http/HttpTunnelServlet.java index acf6adcc45..8b67df8b19 100755 --- a/activemq-optional/src/main/java/org/apache/activemq/transport/http/HttpTunnelServlet.java +++ b/activemq-optional/src/main/java/org/apache/activemq/transport/http/HttpTunnelServlet.java @@ -101,14 +101,21 @@ public class HttpTunnelServlet extends HttpServlet { // String body = readRequestBody(request); // Command command = wireFormat.readCommand(body); - - Command command = wireFormat.readCommand(request.getReader()); - if (command instanceof ConnectionInfo) { - ConnectionInfo info = (ConnectionInfo) command; - request.getSession(true).setAttribute("clientID", info.getClientId()); + // Read the command directly from the reader + //Command command = wireFormat.readCommand(request.getReader()); + + // Build the command xml before passing it to the reader + BufferedReader buffRead = request.getReader(); + String commandXml = ""; + String line; + while ((line = buffRead.readLine()) != null) { + commandXml += line; } - else if (command instanceof WireFormatInfo) { + + Command command = wireFormat.readCommand(commandXml); + + if (command instanceof WireFormatInfo) { WireFormatInfo info = (WireFormatInfo) command; if (!canProcessWireFormatVersion(info.getVersion())) { response.sendError(HttpServletResponse.SC_NOT_FOUND, "Cannot process wire format of version: " + info.getVersion()); @@ -116,6 +123,11 @@ public class HttpTunnelServlet extends HttpServlet { } else { + if (command instanceof ConnectionInfo) { + ConnectionInfo info = (ConnectionInfo) command; + request.getSession(true).setAttribute("clientID", info.getClientId()); + } + BlockingQueueTransport transport = getTransportChannel(request); if (transport == null) { response.setStatus(HttpServletResponse.SC_NOT_FOUND);