Author: asankha
Date: Tue Apr 24 07:52:03 2007
New Revision: 531965

URL: http://svn.apache.org/viewvc?view=rev&rev=531965
Log:
use BuilderUtil to determine the charset encoding from http responses
correctly set the transport name into the axis2 MC for https (note: axis2 still 
does not define a constant for https transport)

Modified:
    
webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/ClientWorker.java
    
webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/HttpCoreNIOListener.java
    
webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/ServerHandler.java
    
webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/ServerWorker.java

Modified: 
webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/ClientWorker.java
URL: 
http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/ClientWorker.java?view=diff&rev=531965&r1=531964&r2=531965
==============================================================================
--- 
webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/ClientWorker.java
 (original)
+++ 
webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/ClientWorker.java
 Tue Apr 24 07:52:03 2007
@@ -23,6 +23,7 @@
 import org.apache.axis2.description.WSDL2Constants;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.Constants;
+import org.apache.axis2.builder.BuilderUtil;
 import org.apache.axis2.wsdl.WSDLConstants;
 import org.apache.axis2.engine.AxisEngine;
 import org.apache.axis2.transport.TransportUtils;
@@ -119,10 +120,13 @@
         SOAPEnvelope envelope = null;
         try {
             String contentType = 
response.getFirstHeader(HTTP.CONTENT_TYPE).getValue();
+            String charSetEnc = BuilderUtil.getCharSetEncoding(contentType);
+            if (charSetEnc == null) {
+                charSetEnc = MessageContext.DEFAULT_CHAR_SET_ENCODING;
+            }
+
             if (contentType.indexOf(HTTP.CHARSET_PARAM) > 0) {
-                
responseMsgCtx.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING,
-                    
contentType.substring(contentType.indexOf(HTTP.CHARSET_PARAM) +
-                    HTTP.CHARSET_PARAM.length()));
+                
responseMsgCtx.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING, 
charSetEnc);
             } else {
                 
responseMsgCtx.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING,
                     MessageContext.DEFAULT_CHAR_SET_ENCODING);

Modified: 
webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/HttpCoreNIOListener.java
URL: 
http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/HttpCoreNIOListener.java?view=diff&rev=531965&r1=531964&r2=531965
==============================================================================
--- 
webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/HttpCoreNIOListener.java
 (original)
+++ 
webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/HttpCoreNIOListener.java
 Tue Apr 24 07:52:03 2007
@@ -80,7 +80,7 @@
             log.error("Error starting the IOReactor", e);
         }
 
-        NHttpServiceHandler handler = new ServerHandler(cfgCtx, params);
+        NHttpServiceHandler handler = new ServerHandler(cfgCtx, params, 
sslContext != null);
         IOEventDispatch ioEventDispatch = getEventDispatch(
             handler, sslContext, sslIOSessionHandler, params);
 

Modified: 
webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/ServerHandler.java
URL: 
http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/ServerHandler.java?view=diff&rev=531965&r1=531964&r2=531965
==============================================================================
--- 
webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/ServerHandler.java
 (original)
+++ 
webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/ServerHandler.java
 Tue Apr 24 07:52:03 2007
@@ -67,6 +67,8 @@
 
     /** the Axis2 configuration context */
     ConfigurationContext cfgCtx = null;
+    /** is this https? */
+    private boolean isHttps = false;
 
     /** the thread pool to process requests */
     private Executor workerPool = null;
@@ -78,10 +80,12 @@
     private static final String REQUEST_BUFFER = "request-buffer";
     private static final String RESPONSE_BUFFER = "response-buffer";
 
-    public ServerHandler(final ConfigurationContext cfgCtx, final HttpParams 
params) {
+    public ServerHandler(final ConfigurationContext cfgCtx, final HttpParams 
params,
+        final boolean isHttps) {
         super();
         this.cfgCtx = cfgCtx;
         this.params = params;
+        this.isHttps = isHttps;
         this.responseFactory = new DefaultHttpResponseFactory();
         this.httpProcessor = getHttpProcessor();
         this.connStrategy = new DefaultConnectionReuseStrategy();
@@ -128,7 +132,7 @@
 
             // hand off processing of the request to a thread off the pool
             workerPool.execute(
-                new ServerWorker(cfgCtx, conn, this,
+                new ServerWorker(cfgCtx, conn, isHttps, this,
                     request, Channels.newInputStream(requestPipe.source()),
                     response, Channels.newOutputStream(responsePipe.sink())));
 

Modified: 
webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/ServerWorker.java
URL: 
http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/ServerWorker.java?view=diff&rev=531965&r1=531964&r2=531965
==============================================================================
--- 
webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/ServerWorker.java
 (original)
+++ 
webservices/synapse/trunk/java/modules/nhttp/src/org/apache/axis2/transport/nhttp/ServerWorker.java
 Tue Apr 24 07:52:03 2007
@@ -61,6 +61,8 @@
     private ServerHandler serverHandler = null;
     /** the underlying http connection */
     private NHttpServerConnection conn = null;
+    /** is this https? */
+    private boolean isHttps = false;
     /** the http request */
     private HttpRequest request = null;
     /** the http response message (which the this would be creating) */
@@ -89,12 +91,14 @@
      * @param os the output stream to write the response body if one is 
applicable
      */
     public ServerWorker(final ConfigurationContext cfgCtx, final 
NHttpServerConnection conn,
+        final boolean isHttps,
         final ServerHandler serverHandler,
         final HttpRequest request, final InputStream is,
         final HttpResponse response, final OutputStream os) {
 
         this.cfgCtx = cfgCtx;
         this.conn = conn;
+        this.isHttps = isHttps;
         this.serverHandler = serverHandler;
         this.request = request;
         this.response = response;
@@ -114,7 +118,19 @@
         MessageContext msgContext = new MessageContext();
         msgContext.setProperty(MessageContext.TRANSPORT_NON_BLOCKING, 
Boolean.TRUE);
         msgContext.setConfigurationContext(cfgCtx);
-        msgContext.setIncomingTransportName(Constants.TRANSPORT_HTTP);
+        if (isHttps) {
+            msgContext.setTransportOut(cfgCtx.getAxisConfiguration()
+                .getTransportOut("https"));
+            msgContext.setTransportIn(cfgCtx.getAxisConfiguration()
+                .getTransportIn("https"));
+            msgContext.setIncomingTransportName("https");
+        } else {
+            msgContext.setTransportOut(cfgCtx.getAxisConfiguration()
+                .getTransportOut(Constants.TRANSPORT_HTTP));
+            msgContext.setTransportIn(cfgCtx.getAxisConfiguration()
+                .getTransportIn(Constants.TRANSPORT_HTTP));
+            msgContext.setIncomingTransportName(Constants.TRANSPORT_HTTP);
+        }
         msgContext.setProperty(Constants.OUT_TRANSPORT_INFO, this);
         msgContext.setServiceGroupContextId(UUIDGenerator.getUUID());
         msgContext.setServerSide(true);
@@ -135,11 +151,6 @@
                 msgContext.setProperty(MessageContext.REMOTE_ADDR, 
remoteAddr.getHostAddress());
             }
         }
-
-        msgContext.setTransportOut(cfgCtx.getAxisConfiguration()
-            .getTransportOut(Constants.TRANSPORT_HTTP));
-        msgContext.setTransportIn(cfgCtx.getAxisConfiguration()
-            .getTransportIn(Constants.TRANSPORT_HTTP));
 
         return msgContext;
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to