You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-dev@xml.apache.org by du...@apache.org on 2001/05/19 19:17:15 UTC

cvs commit: xml-soap/java/src/org/apache/soap/util/net HTTPUtils.java

duftler     01/05/19 10:17:15

  Modified:    java/src/org/apache/soap/transport/http
                        SOAPHTTPConnection.java
               java/src/org/apache/soap/util/net HTTPUtils.java
  Log:
  Committed Scott's changes to enable a SOAPHTTPConnection to explicitly
    set its output buffer size. The default behavior is still excatly the
    same as it was.
  Submitted by: Scott Nichol (snichol@computer.org)
  Reviewed by: Matthew J. Duftler (duftler@us.ibm.com)
  
  Revision  Changes    Path
  1.17      +22 -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.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- SOAPHTTPConnection.java	2001/04/08 13:36:20	1.16
  +++ SOAPHTTPConnection.java	2001/05/19 17:17:14	1.17
  @@ -80,6 +80,7 @@
    * @author Matthew J. Duftler (duftler@us.ibm.com)
    * @author Sanjiva Weerawarana (sanjiva@watson.ibm.com)
    * @author Wouter Cloetens (wcloeten@raleigh.ibm.com)
  + * @author Scott Nichol (snichol@computer.org)
    */
   public class SOAPHTTPConnection implements SOAPTransport {
     private BufferedReader responseReader;
  @@ -96,6 +97,7 @@
     private boolean maintainSession;
     private String cookieHeader;
     private String cookieHeader2;
  +  private int    outputBufferSize = HTTPUtils.DEFAULT_OUTPUT_BUFFER_SIZE;
   
     /**
      * Set HTTP proxy host.
  @@ -203,6 +205,24 @@
     }
   
     /**
  +   * Sets the output buffer size (in bytes).
  +   *
  +   * @param sz The output buffer size (in bytes).
  +   */
  +  public void setOutputBufferSize(int sz) {
  +    outputBufferSize = sz;
  +  }
  +
  +  /**
  +   * Gets the output buffer size (in bytes).
  +   *
  +   * @return The output buffer size (in bytes).
  +   */
  +  public int getOutputBufferSize() {
  +    return outputBufferSize;
  +  }
  +
  +  /**
      * 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.
  @@ -260,7 +280,8 @@
           TransportMessage msg = new TransportMessage(payload, ctx, headers);
           msg.save();
           response = HTTPUtils.post (sendTo, msg,
  -                                   timeout, httpProxyHost, httpProxyPort);
  +                                   timeout, httpProxyHost, httpProxyPort,
  +                                   outputBufferSize);
         } catch (MessagingException me) {
           throw new IOException ("Failed to encode mime multipart: " + me);
         } catch (UnsupportedEncodingException uee) {
  
  
  
  1.20      +31 -2     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.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- HTTPUtils.java	2001/05/17 18:26:11	1.19
  +++ HTTPUtils.java	2001/05/19 17:17:14	1.20
  @@ -78,12 +78,15 @@
    * @author Sanjiva Weerawarana (sanjiva@watson.ibm.com)
    * @author Matthew J. Duftler (duftler@us.ibm.com)
    * @author Wouter Cloetens (wcloeten@raleigh.ibm.com)
  + * @author Scott Nichol (snichol@computer.org)
    */
   public class HTTPUtils {
     private static final String HTTP_VERSION = "1.0";
     private static final int    HTTP_DEFAULT_PORT = 80;
     private static final int    HTTPS_DEFAULT_PORT = 443;
   
  +  public  static final int    DEFAULT_OUTPUT_BUFFER_SIZE = 512;
  +
     /**
      * This method either creates a socket or calls SSLUtils to
      * create an SSLSocket.  It uses reflection to avoid a compile time
  @@ -148,11 +151,38 @@
      * @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
  +   * @return the response message
      */
     public static TransportMessage post(URL url, TransportMessage request,
                                         int timeout,
                                         String httpProxyHost, int httpProxyPort)
         throws IllegalArgumentException, IOException, SOAPException {
  +    return post(url,
  +                request,
  +                timeout,
  +                httpProxyHost,
  +                httpProxyPort,
  +                DEFAULT_OUTPUT_BUFFER_SIZE);
  +  }
  +
  +  /**
  +   * 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
  +   * @return the response message
  +   */
  +  public static TransportMessage post(URL url, TransportMessage request,
  +                                      int timeout,
  +                                      String httpProxyHost, int httpProxyPort,
  +                                      int outputBufferSize)
  +      throws IllegalArgumentException, IOException, SOAPException {
         /* Open the connection */
         OutputStream outStream = null;
         InputStream inStream = null;
  @@ -195,7 +225,7 @@
         headerbuf.append("\r\n");
   
         /* Send the request. */
  -      BufferedOutputStream bOutStream = new BufferedOutputStream(outStream);
  +      BufferedOutputStream bOutStream = new BufferedOutputStream(outStream, outputBufferSize);
         bOutStream.write(
             headerbuf.toString().getBytes(Constants.HEADERVAL_DEFAULT_CHARSET));
         request.writeTo(bOutStream);
  @@ -314,4 +344,3 @@
         return response;
     }
   }
  -