jochen      2005/05/20 19:37:08

  Modified:    src/java/org/apache/xmlrpc/util Tag: b20050512_streaming
                        HttpUtil.java
               src/java/org/apache/xmlrpc/client Tag: b20050512_streaming
                        XmlRpcStreamTransport.java
                        XmlRpcLocalStreamTransport.java
                        XmlRpcLocalStreamTransportFactory.java
                        XmlRpcSunHttpTransportFactory.java
                        XmlRpcCommonsTransport.java
                        XmlRpcSunHttpTransport.java
                        XmlRpcHttpTransport.java
                        XmlRpcCommonsTransportFactory.java
               src/test/org/apache/xmlrpc/test Tag: b20050512_streaming
                        SunHttpTransportProvider.java
                        WebServerProvider.java BaseTest.java
                        CommonsProvider.java
               src/java/org/apache/xmlrpc/webserver Tag:
                        b20050512_streaming Connection.java
  Added:       src/java/org/apache/xmlrpc/util Tag: b20050512_streaming
                        LimitedInputStream.java
               src/java/org/apache/xmlrpc/client Tag: b20050512_streaming
                        XmlRpcLiteHttpTransport.java
                        XmlRpcLiteHttpTransportFactory.java
               src/test/org/apache/xmlrpc/test Tag: b20050512_streaming
                        LiteTransportProvider.java MiniTest.java
  Removed:     src/java/org/apache/xmlrpc/webserver Tag:
                        b20050512_streaming ServerInputStream.java
  Log:
  Ported the Lite transport.
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.4.2.2   +29 -0     ws-xmlrpc/src/java/org/apache/xmlrpc/util/HttpUtil.java
  
  Index: HttpUtil.java
  ===================================================================
  RCS file: /home/cvs/ws-xmlrpc/src/java/org/apache/xmlrpc/util/HttpUtil.java,v
  retrieving revision 1.4.2.1
  retrieving revision 1.4.2.2
  diff -u -r1.4.2.1 -r1.4.2.2
  --- HttpUtil.java     12 May 2005 01:58:53 -0000      1.4.2.1
  +++ HttpUtil.java     21 May 2005 02:37:07 -0000      1.4.2.2
  @@ -15,6 +15,8 @@
    */
   package org.apache.xmlrpc.util;
   
  +import java.io.IOException;
  +import java.io.InputStream;
   import java.io.UnsupportedEncodingException;
   import java.util.StringTokenizer;
   
  @@ -65,4 +67,31 @@
           }
           return false;
       }
  +
  +     /** Reads a header line from the input stream <code>pIn</code>
  +      * and converts it into a string.
  +      * @param pIn The input stream being read.
  +      * @param pBuffer A buffer being used for temporary storage.
  +      * The buffers length is a limit of the header lines length.
  +      * @return Next header line or null, if no more header lines
  +      * are available.
  +      * @throws IOException Reading the header line failed.
  +      */
  +     public static String readLine(InputStream pIn, byte[] pBuffer) throws 
IOException {
  +        int next;
  +        int count = 0;
  +        while (true) {
  +            next = pIn.read();
  +            if (next < 0 || next == '\n') {
  +                break;
  +            }
  +            if (next != '\r') {
  +                pBuffer[count++] = (byte) next;
  +            }
  +            if (count >= pBuffer.length) {
  +                throw new IOException ("HTTP Header too long");
  +            }
  +        }
  +        return new String(pBuffer, 0, count);
  +    }
   }
  
  
  
  No                   revision
  
  Index: HttpUtil.java
  ===================================================================
  RCS file: /home/cvs/ws-xmlrpc/src/java/org/apache/xmlrpc/util/HttpUtil.java,v
  retrieving revision 1.4.2.1
  retrieving revision 1.4.2.2
  diff -u -r1.4.2.1 -r1.4.2.2
  --- HttpUtil.java     12 May 2005 01:58:53 -0000      1.4.2.1
  +++ HttpUtil.java     21 May 2005 02:37:07 -0000      1.4.2.2
  @@ -15,6 +15,8 @@
    */
   package org.apache.xmlrpc.util;
   
  +import java.io.IOException;
  +import java.io.InputStream;
   import java.io.UnsupportedEncodingException;
   import java.util.StringTokenizer;
   
  @@ -65,4 +67,31 @@
           }
           return false;
       }
  +
  +     /** Reads a header line from the input stream <code>pIn</code>
  +      * and converts it into a string.
  +      * @param pIn The input stream being read.
  +      * @param pBuffer A buffer being used for temporary storage.
  +      * The buffers length is a limit of the header lines length.
  +      * @return Next header line or null, if no more header lines
  +      * are available.
  +      * @throws IOException Reading the header line failed.
  +      */
  +     public static String readLine(InputStream pIn, byte[] pBuffer) throws 
IOException {
  +        int next;
  +        int count = 0;
  +        while (true) {
  +            next = pIn.read();
  +            if (next < 0 || next == '\n') {
  +                break;
  +            }
  +            if (next != '\r') {
  +                pBuffer[count++] = (byte) next;
  +            }
  +            if (count >= pBuffer.length) {
  +                throw new IOException ("HTTP Header too long");
  +            }
  +        }
  +        return new String(pBuffer, 0, count);
  +    }
   }
  
  
  
  No                   revision
  
  Index: HttpUtil.java
  ===================================================================
  RCS file: /home/cvs/ws-xmlrpc/src/java/org/apache/xmlrpc/util/HttpUtil.java,v
  retrieving revision 1.4.2.1
  retrieving revision 1.4.2.2
  diff -u -r1.4.2.1 -r1.4.2.2
  --- HttpUtil.java     12 May 2005 01:58:53 -0000      1.4.2.1
  +++ HttpUtil.java     21 May 2005 02:37:07 -0000      1.4.2.2
  @@ -15,6 +15,8 @@
    */
   package org.apache.xmlrpc.util;
   
  +import java.io.IOException;
  +import java.io.InputStream;
   import java.io.UnsupportedEncodingException;
   import java.util.StringTokenizer;
   
  @@ -65,4 +67,31 @@
           }
           return false;
       }
  +
  +     /** Reads a header line from the input stream <code>pIn</code>
  +      * and converts it into a string.
  +      * @param pIn The input stream being read.
  +      * @param pBuffer A buffer being used for temporary storage.
  +      * The buffers length is a limit of the header lines length.
  +      * @return Next header line or null, if no more header lines
  +      * are available.
  +      * @throws IOException Reading the header line failed.
  +      */
  +     public static String readLine(InputStream pIn, byte[] pBuffer) throws 
IOException {
  +        int next;
  +        int count = 0;
  +        while (true) {
  +            next = pIn.read();
  +            if (next < 0 || next == '\n') {
  +                break;
  +            }
  +            if (next != '\r') {
  +                pBuffer[count++] = (byte) next;
  +            }
  +            if (count >= pBuffer.length) {
  +                throw new IOException ("HTTP Header too long");
  +            }
  +        }
  +        return new String(pBuffer, 0, count);
  +    }
   }
  
  
  
  1.1.2.1   +91 -0     
ws-xmlrpc/src/java/org/apache/xmlrpc/util/Attic/LimitedInputStream.java
  
  
  
  
  No                   revision
  No                   revision
  1.1.2.5   +52 -14    
ws-xmlrpc/src/java/org/apache/xmlrpc/client/Attic/XmlRpcStreamTransport.java
  
  Index: XmlRpcStreamTransport.java
  ===================================================================
  RCS file: 
/home/cvs/ws-xmlrpc/src/java/org/apache/xmlrpc/client/Attic/XmlRpcStreamTransport.java,v
  retrieving revision 1.1.2.4
  retrieving revision 1.1.2.5
  diff -u -r1.1.2.4 -r1.1.2.5
  --- XmlRpcStreamTransport.java        14 May 2005 21:17:48 -0000      1.1.2.4
  +++ XmlRpcStreamTransport.java        21 May 2005 02:37:08 -0000      1.1.2.5
  @@ -42,7 +42,6 @@
    * the response,
    */
   public abstract class XmlRpcStreamTransport extends XmlRpcTransportImpl {
  -     private final XmlRpcTransportFactory factory;
        private static final SAXParserFactory spf;
        static {
                spf = SAXParserFactory.newInstance();
  @@ -52,16 +51,8 @@
   
        /** Creates a new instance on behalf of the given client.
         */
  -     protected XmlRpcStreamTransport(XmlRpcClient pClient, 
XmlRpcTransportFactory pFactory) {
  +     protected XmlRpcStreamTransport(XmlRpcClient pClient) {
                super(pClient);
  -             factory = pFactory;
  -     }
  -
  -     /** Returns the factory, which created this transport.
  -      * @return The transport factory.
  -      */
  -     public XmlRpcTransportFactory getFactory() {
  -             return factory;
        }
   
        /** Creates the connection object. The connection object is a
  @@ -126,6 +117,18 @@
        protected abstract InputStream newInputStream(XmlRpcStreamRequestConfig 
pConfig, Object pConnection)
                        throws XmlRpcException;
   
  +     /** Creates a new input stream for reading the response.
  +      * @param pConfig The clients configuration.
  +      * @param pConnection The connection object.
  +      * @param pContent A byte array with the response.
  +      * @return Opened input stream for reading data.
  +      * @throws XmlRpcException Creating the input stream failed.
  +      */
  +     protected abstract InputStream newInputStream(XmlRpcStreamRequestConfig 
pConfig,
  +                                                                             
                  Object pConnection,
  +                                                                             
                  byte[] pContent)
  +                     throws XmlRpcException;
  +
        /** Closes the opened input stream, indicating that no more data is 
being
         * read.
         * @param pStream The stream being closed.
  @@ -146,9 +149,15 @@
         */
        protected abstract boolean 
isResponseGzipCompressed(XmlRpcStreamRequestConfig pConfig, Object pConnection);
   
  -     protected InputStream getInputStream(XmlRpcStreamRequestConfig pConfig, 
Object pConnection)
  +     protected InputStream getInputStream(XmlRpcStreamRequestConfig pConfig, 
Object pConnection,
  +                                                                             
 byte[] pContent)
                        throws XmlRpcException {
  -             InputStream istream = newInputStream(pConfig, pConnection);
  +             InputStream istream;
  +             if (pContent == null) {
  +                     istream = newInputStream(pConfig, pConnection);
  +             } else {
  +                     istream = newInputStream(pConfig, pConnection, 
pContent);
  +             }
                if (isResponseGzipCompressed(pConfig, pConnection)) {
                        try {
                                istream = new GZIPInputStream(istream);
  @@ -159,12 +168,41 @@
                return istream;
        }
   
  +     /** If this method returns true, then the method
  +      * [EMAIL PROTECTED] #newInputStream(XmlRpcStreamRequestConfig, Object, 
byte[])}
  +      * will be invoked to create the response. Otherwise, the methods
  +      * [EMAIL PROTECTED] #getOutputStream(XmlRpcStreamRequestConfig, 
Object)}, and
  +      * [EMAIL PROTECTED] #newInputStream(XmlRpcStreamRequestConfig, 
Object)} will
  +      * be used.
  +      * @return Whether conversion into a byte array is required to create
  +      * the response.
  +      */
  +     protected boolean isUsingByteArrayOutput(XmlRpcStreamRequestConfig 
pConfig) {
  +             return false;
  +     }
  +
        public Object sendRequest(XmlRpcRequest pRequest) throws 
XmlRpcException {
                XmlRpcStreamRequestConfig config = (XmlRpcStreamRequestConfig) 
pRequest.getConfig();
                Object connection = newConnection(config);
                try {
                        initConnection(config, connection);
  -                     OutputStream ostream = getOutputStream(config, 
connection);
  +                     OutputStream ostream;
  +                     ByteArrayOutputStream baos;
  +                     if (isUsingByteArrayOutput(config)) {
  +                             baos = new ByteArrayOutputStream();
  +                             if (config.isGzipCompressing()) {
  +                                     try {
  +                                             ostream = new 
GZIPOutputStream(baos);
  +                                     } catch (IOException e) {
  +                                             throw new 
XmlRpcClientException("Failed to create GZIPOutputStream: " + e.getMessage(), 
e);
  +                                     }
  +                             } else {
  +                                     ostream = baos;
  +                             }
  +                     } else {
  +                             baos = null;
  +                             ostream = getOutputStream(config, connection);
  +                     }
                        try {
                                writeRequest(config, ostream, pRequest);
                                closeOutputStream(ostream);
  @@ -172,7 +210,7 @@
                        } finally {
                                if (ostream != null) { try { 
closeOutputStream(ostream); } catch (Throwable ignore) {} }
                        }
  -                     InputStream istream = getInputStream(config, 
connection);
  +                     InputStream istream = getInputStream(config, 
connection, baos == null ? null : baos.toByteArray());
                        Object result;
                        try {
                                result = readResponse(config, istream);
  
  
  
  1.1.2.2   +6 -3      
ws-xmlrpc/src/java/org/apache/xmlrpc/client/Attic/XmlRpcLocalStreamTransport.java
  
  Index: XmlRpcLocalStreamTransport.java
  ===================================================================
  RCS file: 
/home/cvs/ws-xmlrpc/src/java/org/apache/xmlrpc/client/Attic/XmlRpcLocalStreamTransport.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- XmlRpcLocalStreamTransport.java   12 May 2005 01:58:51 -0000      1.1.2.1
  +++ XmlRpcLocalStreamTransport.java   21 May 2005 02:37:08 -0000      1.1.2.2
  @@ -65,10 +65,9 @@
   
        /** Creates a new instance.
         * @param pClient The client, which is controlling the transport.
  -      * @param pFactory The factory creating the transport.
         */
  -     public XmlRpcLocalStreamTransport(XmlRpcClient pClient, 
XmlRpcLocalStreamTransportFactory pFactory) {
  -             super(pClient, pFactory);
  +     public XmlRpcLocalStreamTransport(XmlRpcClient pClient) {
  +             super(pClient);
        }
   
        protected Object newConnection(XmlRpcStreamRequestConfig pConfig) 
throws XmlRpcClientException {
  @@ -102,4 +101,8 @@
        protected boolean isResponseGzipCompressed(XmlRpcStreamRequestConfig 
pConfig, Object pConnection) {
                return pConfig.isGzipRequesting();
        }
  +
  +     protected InputStream newInputStream(XmlRpcStreamRequestConfig pConfig, 
Object pConnection, byte[] pContent) throws XmlRpcException {
  +             throw new IllegalStateException("Not implemented");
  +     }
   }
  
  
  
  1.1.2.2   +1 -1      
ws-xmlrpc/src/java/org/apache/xmlrpc/client/Attic/XmlRpcLocalStreamTransportFactory.java
  
  Index: XmlRpcLocalStreamTransportFactory.java
  ===================================================================
  RCS file: 
/home/cvs/ws-xmlrpc/src/java/org/apache/xmlrpc/client/Attic/XmlRpcLocalStreamTransportFactory.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- XmlRpcLocalStreamTransportFactory.java    12 May 2005 01:58:51 -0000      
1.1.2.1
  +++ XmlRpcLocalStreamTransportFactory.java    21 May 2005 02:37:08 -0000      
1.1.2.2
  @@ -30,7 +30,7 @@
         */
        public XmlRpcLocalStreamTransportFactory(XmlRpcClient pClient) {
                super(pClient);
  -             LOCAL_STREAM_TRANSPORT = new 
XmlRpcLocalStreamTransport(pClient, this);
  +             LOCAL_STREAM_TRANSPORT = new 
XmlRpcLocalStreamTransport(pClient);
        }
   
        public XmlRpcTransport getTransport() { return LOCAL_STREAM_TRANSPORT; }
  
  
  
  1.1.2.2   +1 -1      
ws-xmlrpc/src/java/org/apache/xmlrpc/client/Attic/XmlRpcSunHttpTransportFactory.java
  
  Index: XmlRpcSunHttpTransportFactory.java
  ===================================================================
  RCS file: 
/home/cvs/ws-xmlrpc/src/java/org/apache/xmlrpc/client/Attic/XmlRpcSunHttpTransportFactory.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- XmlRpcSunHttpTransportFactory.java        14 May 2005 21:17:48 -0000      
1.1.2.1
  +++ XmlRpcSunHttpTransportFactory.java        21 May 2005 02:37:08 -0000      
1.1.2.2
  @@ -29,7 +29,7 @@
         */
        public XmlRpcSunHttpTransportFactory(XmlRpcClient pClient) {
                super(pClient);
  -             HTTP_TRANSPORT = new XmlRpcSunHttpTransport(getClient(), this);
  +             HTTP_TRANSPORT = new XmlRpcSunHttpTransport(pClient);
         }
   
        public XmlRpcTransport getTransport() { return HTTP_TRANSPORT; }
  
  
  
  1.1.2.2   +20 -8     
ws-xmlrpc/src/java/org/apache/xmlrpc/client/Attic/XmlRpcCommonsTransport.java
  
  Index: XmlRpcCommonsTransport.java
  ===================================================================
  RCS file: 
/home/cvs/ws-xmlrpc/src/java/org/apache/xmlrpc/client/Attic/XmlRpcCommonsTransport.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- XmlRpcCommonsTransport.java       14 May 2005 21:17:48 -0000      1.1.2.1
  +++ XmlRpcCommonsTransport.java       21 May 2005 02:37:08 -0000      1.1.2.2
  @@ -42,22 +42,22 @@
        private class CommonsConnection {
                final HttpClient client = new HttpClient();
                final PostMethod method;
  -             final ByteArrayOutputStream content = new 
ByteArrayOutputStream();
                CommonsConnection(XmlRpcHttpClientConfig pConfig) {
                        method = new 
PostMethod(pConfig.getServerURL().toString());
                method.setHttp11(true);
                }
        }
   
  +     private String userAgent = super.getUserAgent() + " (Jakarta Commons 
httpclient Transport)";
  +
        /** Creates a new instance.
         * @param pClient The client, which will be invoking the transport.
  -      * @param pFactory The factory, which is creating the transport.
         */
  -     public XmlRpcCommonsTransport(XmlRpcClient pClient, 
XmlRpcTransportFactoryImpl pFactory) {
  -             super(pClient, pFactory);
  +     public XmlRpcCommonsTransport(XmlRpcClient pClient) {
  +             super(pClient);
        }
   
  -     protected String getUserAgent() { return super.getUserAgent() + " 
(Jakarta Commons httpclient Transport)"; }
  +     protected String getUserAgent() { return userAgent; }
   
        protected void setRequestHeader(Object pConnection, String pHeader, 
String pValue) {
                PostMethod method = ((CommonsConnection) pConnection).method;
  @@ -82,15 +82,27 @@
        }
   
        protected OutputStream newOutputStream(XmlRpcStreamRequestConfig 
pConfig, Object pConnection) throws XmlRpcClientException {
  -             return ((CommonsConnection) pConnection).content;
  +             throw new IllegalStateException("Not implemented");
        }
   
  +     protected boolean isUsingByteArrayOutput(XmlRpcStreamRequestConfig 
pConfig) { return true; }
  +
        protected InputStream newInputStream(XmlRpcStreamRequestConfig pConfig, 
Object pConnection) throws XmlRpcException {
  +             throw new IllegalStateException("Not implemented");
  +     }
  +
  +     protected void setContentLength(Object pConnection, int pLength) {
  +             CommonsConnection conn = (CommonsConnection) pConnection;
  +             PostMethod method = conn.method;
  +             method.setRequestContentLength(pLength);
  +     }
  +
  +     protected InputStream newInputStream(XmlRpcStreamRequestConfig pConfig, 
Object pConnection, byte[] pContents)
  +                     throws XmlRpcException {
                XmlRpcHttpClientConfig config = (XmlRpcHttpClientConfig) 
pConfig;
                CommonsConnection conn = (CommonsConnection) pConnection;
                PostMethod method = conn.method;
  -             method.setRequestBody(new 
ByteArrayInputStream(conn.content.toByteArray()));
  -             method.setRequestContentLength(conn.content.size());
  +             method.setRequestBody(new ByteArrayInputStream(pContents));
                HostConfiguration hostConfig;
                try {
                        URI hostURI = new URI(config.getServerURL().toString());
  
  
  
  1.1.2.2   +19 -4     
ws-xmlrpc/src/java/org/apache/xmlrpc/client/Attic/XmlRpcSunHttpTransport.java
  
  Index: XmlRpcSunHttpTransport.java
  ===================================================================
  RCS file: 
/home/cvs/ws-xmlrpc/src/java/org/apache/xmlrpc/client/Attic/XmlRpcSunHttpTransport.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- XmlRpcSunHttpTransport.java       14 May 2005 21:17:48 -0000      1.1.2.1
  +++ XmlRpcSunHttpTransport.java       21 May 2005 02:37:08 -0000      1.1.2.2
  @@ -14,15 +14,16 @@
    * [EMAIL PROTECTED] java.net.HttpURLConnection} class.
    */
   public class XmlRpcSunHttpTransport extends XmlRpcHttpTransport {
  +     private final String userAgent = super.getUserAgent() + " (Sun HTTP 
Transport)";
  +
        /** Creates a new instance.
         * @param pClient The client controlling this instance.
  -      * @param pFactory The factory creating this instance on behalf of the 
client.
         */
  -     public XmlRpcSunHttpTransport(XmlRpcClient pClient, 
XmlRpcTransportFactoryImpl pFactory) {
  -             super(pClient, pFactory);
  +     public XmlRpcSunHttpTransport(XmlRpcClient pClient) {
  +             super(pClient);
        }
   
  -     protected String getUserAgent() { return super.getUserAgent() + " (Sun 
HTTP Transport)"; }
  +     protected String getUserAgent() { return userAgent; }
   
        protected void setRequestHeader(Object pConnection, String pHeader, 
String pValue) {
                URLConnection conn = (URLConnection) pConnection;
  @@ -66,6 +67,20 @@
                }
        }
   
  +     protected InputStream newInputStream(XmlRpcStreamRequestConfig pConfig, 
Object pConnection,
  +                                                                             
 byte[] pContent)
  +                     throws XmlRpcClientException {
  +             URLConnection conn = (URLConnection) pConnection;
  +             try {
  +                     OutputStream ostream = conn.getOutputStream();
  +                     ostream.write(pContent);
  +                     ostream.close();
  +             } catch (IOException e) {
  +                     throw new XmlRpcClientException("Failed to send request 
to server: " + e.getMessage(), e);
  +             }
  +             return newInputStream(pConfig, pConnection);
  +     }
  +
        protected boolean isResponseGzipCompressed(XmlRpcStreamRequestConfig 
pConfig, Object pConnection) {
                if (pConnection instanceof HttpURLConnection) {
                        HttpURLConnection conn = (HttpURLConnection) 
pConnection;
  
  
  
  1.1.2.4   +21 -3     
ws-xmlrpc/src/java/org/apache/xmlrpc/client/Attic/XmlRpcHttpTransport.java
  
  Index: XmlRpcHttpTransport.java
  ===================================================================
  RCS file: 
/home/cvs/ws-xmlrpc/src/java/org/apache/xmlrpc/client/Attic/XmlRpcHttpTransport.java,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- XmlRpcHttpTransport.java  14 May 2005 21:17:48 -0000      1.1.2.3
  +++ XmlRpcHttpTransport.java  21 May 2005 02:37:08 -0000      1.1.2.4
  @@ -1,7 +1,9 @@
   package org.apache.xmlrpc.client;
   
  +import java.io.InputStream;
   import java.io.UnsupportedEncodingException;
   
  +import org.apache.xmlrpc.XmlRpcException;
   import org.apache.xmlrpc.common.XmlRpcStreamRequestConfig;
   import org.apache.xmlrpc.util.HttpUtil;
   
  @@ -15,8 +17,8 @@
         */
        public static final String USER_AGENT = "Apache XML RPC 3.0";
   
  -     protected XmlRpcHttpTransport(XmlRpcClient pClient, 
XmlRpcTransportFactoryImpl pFactory) {
  -             super(pClient, pFactory);
  +     protected XmlRpcHttpTransport(XmlRpcClient pClient) {
  +             super(pClient);
        }
   
        protected abstract void setRequestHeader(Object pConnection, String 
pHeader, String pValue);
  @@ -36,6 +38,17 @@
                }
        }
   
  +     protected void setContentLength(Object pConnection, int pLength) {
  +             setRequestHeader(pConnection, "Content-Length", 
Integer.toString(pLength));
  +     }
  +
  +     protected InputStream getInputStream(XmlRpcStreamRequestConfig pConfig, 
Object pConnection, byte[] pContent) throws XmlRpcException {
  +             if (pContent != null) {
  +                     setContentLength(pConnection, pContent.length);
  +             }
  +             return super.getInputStream(pConfig, pConnection, pContent);
  +     }
  +
        protected void setCompressionHeaders(XmlRpcHttpClientConfig pConfig, 
Object pConnection) {
                if (pConfig.isGzipCompressing()) {
                        setRequestHeader(pConnection, "Content-Encoding", 
"gzip");
  @@ -50,11 +63,16 @@
        protected void initConnection(XmlRpcStreamRequestConfig pConfig, Object 
pConnection) throws XmlRpcClientException {
                super.initConnection(pConfig, pConnection);
                XmlRpcHttpClientConfig config = (XmlRpcHttpClientConfig) 
pConfig;
  -             setRequestHeader(pConnection, "Content-Type", "text/html");
  +             setRequestHeader(pConnection, "Content-Type", "text/xml");
                setRequestHeader(pConnection, "User-Agent", getUserAgent());
                setCredentials(config, pConnection);
                setCompressionHeaders(config, pConnection);
        }
   
        protected abstract boolean 
isResponseGzipCompressed(XmlRpcStreamRequestConfig pConfig, Object pConnection);
  +
  +     protected boolean isUsingByteArrayOutput(XmlRpcStreamRequestConfig 
pConfig) {
  +             return !pConfig.isEnabledForExtensions()
  +                     || !((XmlRpcHttpClientConfig) 
pConfig).isContentLengthOptional();
  +     }
   }
  
  
  
  1.1.2.2   +1 -1      
ws-xmlrpc/src/java/org/apache/xmlrpc/client/Attic/XmlRpcCommonsTransportFactory.java
  
  Index: XmlRpcCommonsTransportFactory.java
  ===================================================================
  RCS file: 
/home/cvs/ws-xmlrpc/src/java/org/apache/xmlrpc/client/Attic/XmlRpcCommonsTransportFactory.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- XmlRpcCommonsTransportFactory.java        14 May 2005 21:17:48 -0000      
1.1.2.1
  +++ XmlRpcCommonsTransportFactory.java        21 May 2005 02:37:08 -0000      
1.1.2.2
  @@ -27,7 +27,7 @@
         */
        public XmlRpcCommonsTransportFactory(XmlRpcClient pClient) {
                super(pClient);
  -             COMMONS_TRANSPORT = new XmlRpcCommonsTransport(pClient, this);
  +             COMMONS_TRANSPORT = new XmlRpcCommonsTransport(pClient);
        }
   
        public XmlRpcTransport getTransport() {
  
  
  
  No                   revision
  
  Index: XmlRpcCommonsTransportFactory.java
  ===================================================================
  RCS file: 
/home/cvs/ws-xmlrpc/src/java/org/apache/xmlrpc/client/Attic/XmlRpcCommonsTransportFactory.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- XmlRpcCommonsTransportFactory.java        14 May 2005 21:17:48 -0000      
1.1.2.1
  +++ XmlRpcCommonsTransportFactory.java        21 May 2005 02:37:08 -0000      
1.1.2.2
  @@ -27,7 +27,7 @@
         */
        public XmlRpcCommonsTransportFactory(XmlRpcClient pClient) {
                super(pClient);
  -             COMMONS_TRANSPORT = new XmlRpcCommonsTransport(pClient, this);
  +             COMMONS_TRANSPORT = new XmlRpcCommonsTransport(pClient);
        }
   
        public XmlRpcTransport getTransport() {
  
  
  
  No                   revision
  
  Index: XmlRpcCommonsTransportFactory.java
  ===================================================================
  RCS file: 
/home/cvs/ws-xmlrpc/src/java/org/apache/xmlrpc/client/Attic/XmlRpcCommonsTransportFactory.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- XmlRpcCommonsTransportFactory.java        14 May 2005 21:17:48 -0000      
1.1.2.1
  +++ XmlRpcCommonsTransportFactory.java        21 May 2005 02:37:08 -0000      
1.1.2.2
  @@ -27,7 +27,7 @@
         */
        public XmlRpcCommonsTransportFactory(XmlRpcClient pClient) {
                super(pClient);
  -             COMMONS_TRANSPORT = new XmlRpcCommonsTransport(pClient, this);
  +             COMMONS_TRANSPORT = new XmlRpcCommonsTransport(pClient);
        }
   
        public XmlRpcTransport getTransport() {
  
  
  
  1.1.2.1   +257 -0    
ws-xmlrpc/src/java/org/apache/xmlrpc/client/Attic/XmlRpcLiteHttpTransport.java
  
  
  
  
  1.1.2.1   +31 -0     
ws-xmlrpc/src/java/org/apache/xmlrpc/client/Attic/XmlRpcLiteHttpTransportFactory.java
  
  
  
  
  No                   revision
  No                   revision
  1.1.2.2   +2 -2      
ws-xmlrpc/src/test/org/apache/xmlrpc/test/Attic/SunHttpTransportProvider.java
  
  Index: SunHttpTransportProvider.java
  ===================================================================
  RCS file: 
/home/cvs/ws-xmlrpc/src/test/org/apache/xmlrpc/test/Attic/SunHttpTransportProvider.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- SunHttpTransportProvider.java     14 May 2005 21:17:48 -0000      1.1.2.1
  +++ SunHttpTransportProvider.java     21 May 2005 02:37:08 -0000      1.1.2.2
  @@ -30,8 +30,8 @@
        /** Creates a new instance.
         * @param pMapping The test servers handler mapping.
         */
  -     public SunHttpTransportProvider(XmlRpcHandlerMapping pMapping) {
  -             super(pMapping);
  +     public SunHttpTransportProvider(XmlRpcHandlerMapping pMapping, boolean 
pContentLength) {
  +             super(pMapping, pContentLength);
        }
   
        protected XmlRpcTransportFactory getTransportFactory(XmlRpcClient 
pClient) {
  
  
  
  1.1.2.2   +5 -1      
ws-xmlrpc/src/test/org/apache/xmlrpc/test/Attic/WebServerProvider.java
  
  Index: WebServerProvider.java
  ===================================================================
  RCS file: 
/home/cvs/ws-xmlrpc/src/test/org/apache/xmlrpc/test/Attic/WebServerProvider.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- WebServerProvider.java    14 May 2005 21:17:48 -0000      1.1.2.1
  +++ WebServerProvider.java    21 May 2005 02:37:08 -0000      1.1.2.2
  @@ -29,12 +29,14 @@
   public abstract class WebServerProvider extends ClientProviderImpl {
        protected final WebServer webServer = new WebServer(0);
        private boolean isActive;
  +     private final boolean contentLength;
   
        /** Creates a new instance.
         * @param pMapping The test servers handler mapping.
         */
  -     protected WebServerProvider(XmlRpcHandlerMapping pMapping) {
  +     protected WebServerProvider(XmlRpcHandlerMapping pMapping, boolean 
pContentLength) {
                super(pMapping);
  +             contentLength = pContentLength;
        }
   
        public final XmlRpcClientConfigImpl getConfig() throws Exception {
  @@ -45,6 +47,7 @@
        protected XmlRpcClientConfigImpl getConfig(URL pServerURL) throws 
Exception {
                XmlRpcClientConfigImpl config = super.getConfig();
                config.setServerURL(pServerURL);
  +             config.setContentLengthOptional(!contentLength);
                return config;
        }
   
  @@ -54,6 +57,7 @@
                        server.setHandlerMapping(mapping);
                        XmlRpcServerConfigImpl serverConfig = 
(XmlRpcServerConfigImpl) server.getConfig();
                        serverConfig.setEnabledForExtensions(true);
  +                     serverConfig.setContentLengthOptional(!contentLength);
                        webServer.start();
                        isActive = true;
                }
  
  
  
  1.1.2.2   +4 -1      
ws-xmlrpc/src/test/org/apache/xmlrpc/test/Attic/BaseTest.java
  
  Index: BaseTest.java
  ===================================================================
  RCS file: 
/home/cvs/ws-xmlrpc/src/test/org/apache/xmlrpc/test/Attic/BaseTest.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- BaseTest.java     14 May 2005 21:17:48 -0000      1.1.2.1
  +++ BaseTest.java     21 May 2005 02:37:08 -0000      1.1.2.2
  @@ -46,7 +46,10 @@
                        providers = new ClientProvider[]{
                                new LocalTransportProvider(mapping),
                                new LocalStreamTransportProvider(mapping),
  -                             new SunHttpTransportProvider(mapping),
  +                             new LiteTransportProvider(mapping, true),
  +                             new LiteTransportProvider(mapping, false),
  +                             new SunHttpTransportProvider(mapping, true),
  +                             new SunHttpTransportProvider(mapping, false),
                                new CommonsProvider(mapping)
                        };
                }
  
  
  
  1.1.2.2   +16 -1     
ws-xmlrpc/src/test/org/apache/xmlrpc/test/Attic/CommonsProvider.java
  
  Index: CommonsProvider.java
  ===================================================================
  RCS file: 
/home/cvs/ws-xmlrpc/src/test/org/apache/xmlrpc/test/Attic/CommonsProvider.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- CommonsProvider.java      14 May 2005 21:17:48 -0000      1.1.2.1
  +++ CommonsProvider.java      21 May 2005 02:37:08 -0000      1.1.2.2
  @@ -1,3 +1,18 @@
  +/*
  + * Copyright 1999,2005 The Apache Software Foundation.
  + * 
  + * Licensed under the Apache License, Version 2.0 (the "License");
  + * you may not use this file except in compliance with the License.
  + * You may obtain a copy of the License at
  + * 
  + *      http://www.apache.org/licenses/LICENSE-2.0
  + * 
  + * Unless required by applicable law or agreed to in writing, software
  + * distributed under the License is distributed on an "AS IS" BASIS,
  + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  + * See the License for the specific language governing permissions and
  + * limitations under the License.
  + */
   package org.apache.xmlrpc.test;
   
   import org.apache.xmlrpc.client.XmlRpcClient;
  @@ -14,7 +29,7 @@
         * @param pMapping The test servers handler mapping.
         */
        public CommonsProvider(XmlRpcHandlerMapping pMapping) {
  -             super(pMapping);
  +             super(pMapping, true);
        }
   
        protected XmlRpcTransportFactory getTransportFactory(XmlRpcClient 
pClient) {
  
  
  
  No                   revision
  
  Index: CommonsProvider.java
  ===================================================================
  RCS file: 
/home/cvs/ws-xmlrpc/src/test/org/apache/xmlrpc/test/Attic/CommonsProvider.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- CommonsProvider.java      14 May 2005 21:17:48 -0000      1.1.2.1
  +++ CommonsProvider.java      21 May 2005 02:37:08 -0000      1.1.2.2
  @@ -1,3 +1,18 @@
  +/*
  + * Copyright 1999,2005 The Apache Software Foundation.
  + * 
  + * Licensed under the Apache License, Version 2.0 (the "License");
  + * you may not use this file except in compliance with the License.
  + * You may obtain a copy of the License at
  + * 
  + *      http://www.apache.org/licenses/LICENSE-2.0
  + * 
  + * Unless required by applicable law or agreed to in writing, software
  + * distributed under the License is distributed on an "AS IS" BASIS,
  + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  + * See the License for the specific language governing permissions and
  + * limitations under the License.
  + */
   package org.apache.xmlrpc.test;
   
   import org.apache.xmlrpc.client.XmlRpcClient;
  @@ -14,7 +29,7 @@
         * @param pMapping The test servers handler mapping.
         */
        public CommonsProvider(XmlRpcHandlerMapping pMapping) {
  -             super(pMapping);
  +             super(pMapping, true);
        }
   
        protected XmlRpcTransportFactory getTransportFactory(XmlRpcClient 
pClient) {
  
  
  
  No                   revision
  
  Index: CommonsProvider.java
  ===================================================================
  RCS file: 
/home/cvs/ws-xmlrpc/src/test/org/apache/xmlrpc/test/Attic/CommonsProvider.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- CommonsProvider.java      14 May 2005 21:17:48 -0000      1.1.2.1
  +++ CommonsProvider.java      21 May 2005 02:37:08 -0000      1.1.2.2
  @@ -1,3 +1,18 @@
  +/*
  + * Copyright 1999,2005 The Apache Software Foundation.
  + * 
  + * Licensed under the Apache License, Version 2.0 (the "License");
  + * you may not use this file except in compliance with the License.
  + * You may obtain a copy of the License at
  + * 
  + *      http://www.apache.org/licenses/LICENSE-2.0
  + * 
  + * Unless required by applicable law or agreed to in writing, software
  + * distributed under the License is distributed on an "AS IS" BASIS,
  + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  + * See the License for the specific language governing permissions and
  + * limitations under the License.
  + */
   package org.apache.xmlrpc.test;
   
   import org.apache.xmlrpc.client.XmlRpcClient;
  @@ -14,7 +29,7 @@
         * @param pMapping The test servers handler mapping.
         */
        public CommonsProvider(XmlRpcHandlerMapping pMapping) {
  -             super(pMapping);
  +             super(pMapping, true);
        }
   
        protected XmlRpcTransportFactory getTransportFactory(XmlRpcClient 
pClient) {
  
  
  
  1.1.2.1   +40 -0     
ws-xmlrpc/src/test/org/apache/xmlrpc/test/Attic/LiteTransportProvider.java
  
  
  
  
  1.1.2.1   +258 -0    
ws-xmlrpc/src/test/org/apache/xmlrpc/test/Attic/MiniTest.java
  
  
  
  
  No                   revision
  No                   revision
  1.1.2.3   +15 -5     
ws-xmlrpc/src/java/org/apache/xmlrpc/webserver/Attic/Connection.java
  
  Index: Connection.java
  ===================================================================
  RCS file: 
/home/cvs/ws-xmlrpc/src/java/org/apache/xmlrpc/webserver/Attic/Connection.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- Connection.java   14 May 2005 21:17:48 -0000      1.1.2.2
  +++ Connection.java   21 May 2005 02:37:08 -0000      1.1.2.3
  @@ -32,6 +32,7 @@
   import org.apache.xmlrpc.server.XmlRpcHttpServerConfig;
   import org.apache.xmlrpc.server.XmlRpcStreamServer;
   import org.apache.xmlrpc.util.Base64;
  +import org.apache.xmlrpc.util.LimitedInputStream;
   import org.apache.xmlrpc.util.ThreadPool;
   
   
  @@ -92,7 +93,14 @@
                socket = pSocket;
                // set read timeout to 30 seconds
           socket.setSoTimeout (30000);
  -        input = new BufferedInputStream(socket.getInputStream());
  +        input = new BufferedInputStream(socket.getInputStream()){
  +             /** It may happen, that the XML parser invokes close().
  +              * Closing the input stream must not occur, because
  +              * that would close the whole socket. So we suppress it.
  +              */
  +             public void close() throws IOException {
  +             }
  +        };
           output = new BufferedOutputStream(socket.getOutputStream());
        }
   
  @@ -218,7 +226,7 @@
                if (contentLength == -1) {
                        return input;
                } else {
  -                     return new ServerInputStream(input, contentLength);
  +                     return new LimitedInputStream(input, contentLength);
                }
        }
   
  @@ -266,11 +274,13 @@
           output.write(serverName);
           output.write(pData.isKeepAlive() ? conkeep : conclose);
           output.write(ctype);
  -        output.write(clength);
                if (pContentLength != -1) {
  +             output.write(clength);
                        
output.write(toHTTPBytes(Integer.toString(pContentLength)));
  +             output.write(doubleNewline);
  +             } else {
  +                     output.write(newline);
                }
  -        output.write(doubleNewline);
                pData.setSuccess(true);
        }
   
  @@ -318,8 +328,8 @@
                output.write(serverName);
                output.write(conclose);
                output.write(ctype);
  -             output.write(clength);
                        if (pContentLength != -1) {
  +                     output.write(clength);
                                
output.write(toHTTPBytes(Integer.toString(pContentLength)));
                        }
                output.write(doubleNewline);
  
  
  

Reply via email to