nagy        02/05/23 11:20:23

  Modified:    java/docs changes.html
               java/src/org/apache/soap/transport/http
                        SOAPHTTPConnection.java
               java/src/org/apache/soap/util/net HTTPUtils.java
  Log:
  Added mechanism to set TcpNoDelay on the socket for HTTP requests.
  
  Revision  Changes    Path
  1.21      +2 -0      xml-soap/java/docs/changes.html
  
  Index: changes.html
  ===================================================================
  RCS file: /home/cvs/xml-soap/java/docs/changes.html,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- changes.html      17 May 2002 18:19:58 -0000      1.20
  +++ changes.html      23 May 2002 18:20:22 -0000      1.21
  @@ -257,6 +257,8 @@
       the mapping QName being made optional.
       <LI>Made the XMLParserUtils.getXMLDocBuilder() method
       synchronized.
  +    <LI>Added support for turning off Nagle's algorithm
  +    under TCP (HTTP).
     </UL>
   </UL>
    <UL> 
  
  
  
  1.21      +19 -1     
xml-soap/java/src/org/apache/soap/transport/http/SOAPHTTPConnection.java
  
  Index: SOAPHTTPConnection.java
  ===================================================================
  RCS file: 
/home/cvs/xml-soap/java/src/org/apache/soap/transport/http/SOAPHTTPConnection.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- SOAPHTTPConnection.java   1 Feb 2002 21:22:09 -0000       1.20
  +++ SOAPHTTPConnection.java   23 May 2002 18:20:22 -0000      1.21
  @@ -98,6 +98,7 @@
     private String cookieHeader;
     private String cookieHeader2;
     private int    outputBufferSize = HTTPUtils.DEFAULT_OUTPUT_BUFFER_SIZE;
  +  private Boolean tcpNoDelay = null;
   
     /**
      * Set HTTP proxy host.
  @@ -232,6 +233,23 @@
     }
   
     /**
  +   * Get the TCPNoDelay setting.
  +   *
  +   * @return the TCPNoDelay setting.
  +   */
  +  public Boolean getTcpNoDelay() {
  +    return tcpNoDelay;
  +  }
  +
  +  /**
  +   * Set the TCPNoDelay setting.  Setting this to true will disable
  +   * Nagle's algorithm for TCP.  The default is false.
  +   */
  +  public void setTcpNoDelay(Boolean nodelay) {
  +    tcpNoDelay = nodelay;
  +  }
  +
  +  /**
      * This method is used to request that an envelope be posted to the
      * given URL. The response (if any) must be gotten by calling the
      * receive() function.
  @@ -290,7 +308,7 @@
           msg.save();
           response = HTTPUtils.post (sendTo, msg,
                                      timeout, httpProxyHost, httpProxyPort,
  -                                   outputBufferSize);
  +                                   outputBufferSize, tcpNoDelay);
         } catch (MessagingException me) {
           throw new IOException ("Failed to encode mime multipart: " + me);
         } catch (UnsupportedEncodingException uee) {
  
  
  
  1.26      +40 -3     xml-soap/java/src/org/apache/soap/util/net/HTTPUtils.java
  
  Index: HTTPUtils.java
  ===================================================================
  RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/util/net/HTTPUtils.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- HTTPUtils.java    7 May 2002 20:09:19 -0000       1.25
  +++ HTTPUtils.java    23 May 2002 18:20:22 -0000      1.26
  @@ -95,7 +95,8 @@
      * @author Chris Nelson
      */
     private static Socket buildSocket(URL url, int targetPort,
  -                                    String httpProxyHost, int httpProxyPort)
  +                                    String httpProxyHost, int httpProxyPort,
  +                                 Boolean tcpNoDelay)
        throws Exception {
         Socket s = null;
         String host = null;
  @@ -119,6 +120,12 @@
             }
             s = new Socket(host, port);
         }
  +      
  +      if (tcpNoDelay != null)
  +      {
  +     if (s != null) 
  +       s.setTcpNoDelay(tcpNoDelay.booleanValue());
  +      }
   
         return s;
      }
  @@ -160,7 +167,8 @@
                   timeout,
                   httpProxyHost,
                   httpProxyPort,
  -                DEFAULT_OUTPUT_BUFFER_SIZE);
  +                DEFAULT_OUTPUT_BUFFER_SIZE,
  +             null);
     }
   
     /**
  @@ -181,6 +189,35 @@
                                         String httpProxyHost, int httpProxyPort,
                                         int outputBufferSize)
         throws IllegalArgumentException, IOException, SOAPException {
  +    return post(url,
  +                request,
  +                timeout,
  +                httpProxyHost,
  +                httpProxyPort,
  +                outputBufferSize,
  +             null);
  +  }
  +
  +  /**
  +   * POST something to the given URL. The headers are put in as
  +   * HTTP headers, the content length is calculated and the content
  +   * byte array is sent as the POST content.
  +   *
  +   * @param url the url to post to
  +   * @param request the message
  +   * @param timeout the amount of time, in ms, to block on reading data
  +   * @param httpProxyHost the HTTP proxy host or null if no proxy
  +   * @param httpProxyPort the HTTP proxy port, if the proxy host is not null
  +   * @param outputBufferSize the size of the output buffer on the HTTP stream
  +   * @param tcpNoDelay the tcpNoDelay setting for the socket
  +   * @return the response message
  +   */
  +  public static TransportMessage post(URL url, TransportMessage request,
  +                                      int timeout,
  +                                      String httpProxyHost, int httpProxyPort,
  +                                      int outputBufferSize,
  +                                   Boolean tcpNoDelay)
  +      throws IllegalArgumentException, IOException, SOAPException {
         /* Open the connection */
         OutputStream outStream = null;
         InputStream inStream = null;
  @@ -190,7 +227,7 @@
         try {
             port = getPort(url);
   
  -          s = buildSocket(url, port, httpProxyHost, httpProxyPort);
  +          s = buildSocket(url, port, httpProxyHost, httpProxyPort, tcpNoDelay);
             if (url.getProtocol().equalsIgnoreCase("HTTPS")) {
                // Ignore proxy from now on. Buildsocket takes handles it
                httpProxyHost = null;
  
  
  


Reply via email to