axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r232806 - in /webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http: HTTPWorker.java server/SimpleHttpServerConnection.java
Date Mon, 15 Aug 2005 12:56:25 GMT
Author: dims
Date: Mon Aug 15 05:56:23 2005
New Revision: 232806

URL: http://svn.apache.org/viewcvs?rev=232806&view=rev
Log:
Check if reading the whole input stream helps...set SO_TIMEOUT as well.


Modified:
    webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPWorker.java
    webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/server/SimpleHttpServerConnection.java

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPWorker.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPWorker.java?rev=232806&r1=232805&r2=232806&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPWorker.java
(original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPWorker.java
Mon Aug 15 05:56:23 2005
@@ -117,11 +117,19 @@
                 if (!processed) {
                     response.setStatusLine(request.getRequestLine().getHttpVersion(), 200,
"OK");
                     response.setBodyString(HTTPTransportReceiver.getServicesHTML(configurationContext));
-                    setResponseHeaders(conn, request, response);
+                    setResponseHeaders(conn, request, response);
                     conn.writeResponse(response);
                     return true;
                 }
             } else {
+                ByteArrayOutputStream baosIn = new ByteArrayOutputStream();
+                byte[] bytes = new byte[8192];
+                int size = 0;
+                while ((size = inStream.read(bytes)) != -1) {
+                    baosIn.write(bytes, 0, size);
+                }
+                inStream = new ByteArrayInputStream(baosIn.toByteArray());
+
                 //It is POST, handle it
                 HTTPTransportUtils.processHTTPPostRequest(
                         msgContext,
@@ -133,7 +141,7 @@
                         configurationContext);
             }
             response.setStatusLine(request.getRequestLine().getHttpVersion(), 200, "OK");
-            response.setBody(new ByteArrayInputStream(baos.toByteArray()));
+            response.setBody(new ByteArrayInputStream(baos.toByteArray()));
             setResponseHeaders(conn, request, response);
             conn.writeResponse(response);
         } catch (Throwable e) {
@@ -145,7 +153,7 @@
                     response.setStatusLine(request.getRequestLine().getHttpVersion(), 500,
"Internal server error");
                     engine.sendFault(faultContext);
                     response.setBody(new ByteArrayInputStream(baos.toByteArray()));
-                    setResponseHeaders(conn, request, response);
+                    setResponseHeaders(conn, request, response);
                     conn.writeResponse(response);
                 } else {
                     log.error(e, e);
@@ -156,33 +164,32 @@
             log.error(e.getMessage(), e);
         }
         return true;
-    }
-
-    private void setResponseHeaders(final SimpleHttpServerConnection conn, SimpleRequest
request, SimpleResponse response) {
-        if (!response.containsHeader("Connection")) {
-            // See if the the client explicitly handles connection persistence
-            Header connheader = request.getFirstHeader("Connection");
-            if (connheader != null) {
-                if (connheader.getValue().equalsIgnoreCase("keep-alive")) {
-                    Header header = new Header("Connection", "keep-alive"); 
-                    response.addHeader(header);
-                    conn.setKeepAlive(true);
-                }
-                if (connheader.getValue().equalsIgnoreCase("close")) {
-                    Header header = new Header("Connection", "close"); 
-                    response.addHeader(header);
-                    conn.setKeepAlive(false);
-                }
-            } else {
-                // Use protocol default connection policy
-                if (response.getHttpVersion().greaterEquals(HttpVersion.HTTP_1_1)) {
-                    conn.setKeepAlive(true);
-                } else {
-                    conn.setKeepAlive(false);
-                }
-            }
-        }
-        System.out.println("HTTPWorker.isKeepAlive : " + conn.isKeepAlive());
+    }
+
+    private void setResponseHeaders(final SimpleHttpServerConnection conn, SimpleRequest
request, SimpleResponse response) {
+        if (!response.containsHeader("Connection")) {
+            // See if the the client explicitly handles connection persistence
+            Header connheader = request.getFirstHeader("Connection");
+            if (connheader != null) {
+                if (connheader.getValue().equalsIgnoreCase("keep-alive")) {
+                    Header header = new Header("Connection", "keep-alive");
+                    response.addHeader(header);
+                    conn.setKeepAlive(true);
+                }
+                if (connheader.getValue().equalsIgnoreCase("close")) {
+                    Header header = new Header("Connection", "close");
+                    response.addHeader(header);
+                    conn.setKeepAlive(false);
+                }
+            } else {
+                // Use protocol default connection policy
+                if (response.getHttpVersion().greaterEquals(HttpVersion.HTTP_1_1)) {
+                    conn.setKeepAlive(true);
+                } else {
+                    conn.setKeepAlive(false);
+                }
+            }
+        }
     }
 
     private Map getHeaders(SimpleRequest request) {

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/server/SimpleHttpServerConnection.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/server/SimpleHttpServerConnection.java?rev=232806&r1=232805&r2=232806&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/server/SimpleHttpServerConnection.java
(original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/server/SimpleHttpServerConnection.java
Mon Aug 15 05:56:23 2005
@@ -65,6 +65,7 @@
         }
         this.socket = socket;
         this.socket.setTcpNoDelay(true);
+        this.socket.setSoTimeout(500);
         this.in = socket.getInputStream();
         this.out = socket.getOutputStream();
     }



Mime
View raw message