Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@apache.org Received: (qmail 2628 invoked from network); 16 Jul 2002 22:57:38 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 16 Jul 2002 22:57:38 -0000 Received: (qmail 742 invoked by uid 97); 16 Jul 2002 22:57:55 -0000 Delivered-To: qmlist-jakarta-archive-commons-dev@jakarta.apache.org Received: (qmail 726 invoked by uid 97); 16 Jul 2002 22:57:55 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 688 invoked by uid 97); 16 Jul 2002 22:57:54 -0000 X-Antivirus: nagoya (v4198 created Apr 24 2002) Date: 16 Jul 2002 22:57:30 -0000 Message-ID: <20020716225730.96026.qmail@icarus.apache.org> From: morgand@apache.org To: jakarta-commons-cvs@apache.org Subject: cvs commit: jakarta-commons/latka/src/java/org/apache/commons/latka/http Request.java RequestImpl.java Session.java SessionImpl.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N morgand 2002/07/16 15:57:30 Modified: latka/src/java/org/apache/commons/latka/http Request.java RequestImpl.java Session.java SessionImpl.java Log: adding HTTP/1.0 support - patch submitted by Ryan Lubke Revision Changes Path 1.16 +9 -0 jakarta-commons/latka/src/java/org/apache/commons/latka/http/Request.java Index: Request.java =================================================================== RCS file: /home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/http/Request.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- Request.java 15 Jul 2002 16:10:26 -0000 1.15 +++ Request.java 16 Jul 2002 22:57:29 -0000 1.16 @@ -209,4 +209,13 @@ */ void setRequestBody(String body); + /** + * Sets the version of HTTP that is used in the request. + * If the version of HTTP specified is not 1.0 or 1.1, + * then the default of 1.1 will be used. + * + * @param version HTTP version. + */ + void setVersion(String version); + } 1.25 +20 -1 jakarta-commons/latka/src/java/org/apache/commons/latka/http/RequestImpl.java Index: RequestImpl.java =================================================================== RCS file: /home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/http/RequestImpl.java,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- RequestImpl.java 15 Jul 2002 16:10:26 -0000 1.24 +++ RequestImpl.java 16 Jul 2002 22:57:30 -0000 1.25 @@ -70,6 +70,7 @@ import org.apache.commons.httpclient.HttpException; import org.apache.commons.httpclient.HttpMethod; import org.apache.commons.httpclient.HttpState; +import org.apache.commons.httpclient.HttpMethodBase; import org.apache.commons.httpclient.methods.GetMethod; import org.apache.commons.httpclient.methods.HeadMethod; import org.apache.commons.httpclient.methods.PostMethod; @@ -128,6 +129,12 @@ protected static final Category _log = Category.getInstance(RequestImpl.class); + + /** + * HTTP Version 1.0 + */ + private static final String HTTP_10 = "1.0"; + /** * Create a request for the specified URL, process using the supplied method * and use the supplied state and session for persistent data @@ -513,4 +520,16 @@ _proxy = proxy; } + /** + * Sets the HTTP version for this request. If + * the version provided is not 1.0 or 1.1, then + * 1.1 will be used. + * + * @param version HTTP version + */ + public void setVersion(String version) { + if (version.equals(HTTP_10)) { + ((HttpMethodBase) _httpMethod).setHttp11(false); + } + } } 1.11 +23 -13 jakarta-commons/latka/src/java/org/apache/commons/latka/http/Session.java Index: Session.java =================================================================== RCS file: /home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/http/Session.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- Session.java 4 Jul 2002 14:06:32 -0000 1.10 +++ Session.java 16 Jul 2002 22:57:30 -0000 1.11 @@ -75,25 +75,31 @@ public interface Session { /** - * Creates a request object with the specified URL and HTTP Method. + * Creates a request object with the specified URL, HTTP Method, + * and version. * * @param url The URL to request of the HTTP server. * @param httpMethod An integer representing the HTTP method (e.g. GET, PUT) * used to communicate with server. + * @param version A String representing the version of the HTTP request, i.e. + * 1.0 or 1.1. * @return a new {@link Request} object representing the url * and httpMethod * @see org.apache.commons.latka.http.Request#HTTP_METHOD_GET * @see org.apache.commons.latka.http.Request#HTTP_METHOD_POST */ - Request createRequest(URL url, int httpMethod); + Request createRequest(URL url, int httpMethod, String version); - /** Create a request with the given label, to access the given URL via the - * given HTTP method, and follow redirects as specified. + /** + * Creates a labeled request object, with the specified URL, HTTP Method, + * version, and redirect handling behavior. * * @param label a name used to identify the request * @param url The URL to request of the HTTP server. * @param httpMethod An integer representing the HTTP method (e.g. GET, PUT) * used to communicate with server. + * @param version A String representing the version of the HTTP request, i.e. + * 1.0 or 1.1. * @param followRedirects whether to follow HTTP redirection responses * @return a new {@link Request} object representing the url * and httpMethod @@ -101,32 +107,36 @@ * @see org.apache.commons.latka.http.Request#HTTP_METHOD_POST */ Request createRequest(String label, URL url, int httpMethod, - boolean followRedirects); + String version, boolean followRedirects); /** - * Creates a request object with the specified URL and HTTP Method to be - * accessed via the provided proxy + * Creates a request object with the specified URL, HTTP Method, and + * version to be accessed via the provided proxy. * * @param url The URL to request of the HTTP server. * @param httpMethod An integer representing the HTTP method (e.g. GET, PUT) * used to communicate with server. * @param proxy a proxy to use during the request + * @param version A String representing the version of the HTTP request, i.e. + * 1.0 or 1.1. * @return a new {@link Request} object representing the url * and httpMethod. * @see org.apache.commons.latka.http.Request#HTTP_METHOD_GET * @see org.apache.commons.latka.http.Request#HTTP_METHOD_POST * @see org.apache.commons.latka.http.Proxy */ - Request createRequest(URL url, int httpMethod, Proxy proxy); + Request createRequest(URL url, int httpMethod, Proxy proxy, String version); - /** Create a request with the given label, to access the given URL via the - * given HTTP method, and follow redirects as specified, using the given - * proxy for communications + /** + * Create a labeled request with the specified URL, HTTP method, version, and + * redirect handling behavior, using the given proxy for communication. * * @param label a name used to identify the request * @param url The URL to request of the HTTP server. * @param httpMethod An integer representing the HTTP method (e.g. GET, PUT) * used to communicate with server. + * @param version A String representing the version of the HTTP request, i.e. + * 1.0 or 1.1. * @param followRedirects whether to follow HTTP redirection responses * @param proxy a proxy to use during the request * @return a new {@link Request} object representing the url @@ -136,7 +146,7 @@ * @see org.apache.commons.latka.http.Proxy */ Request createRequest(String label, URL url, int httpMethod, - boolean followRedirects, Proxy proxy); + String version, boolean followRedirects, Proxy proxy); /** * Adds a cookie to all HTTP requests whose domain and path match 1.14 +29 -17 jakarta-commons/latka/src/java/org/apache/commons/latka/http/SessionImpl.java Index: SessionImpl.java =================================================================== RCS file: /home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/http/SessionImpl.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- SessionImpl.java 4 Jul 2002 14:06:32 -0000 1.13 +++ SessionImpl.java 16 Jul 2002 22:57:30 -0000 1.14 @@ -100,29 +100,36 @@ /////////////////////////////// /** - * Creates a request object with the specified URL and HTTP Method. - * + * Creates a request object with the specified URL, HTTP Method, + * and version. + * * @param url The URL to request of the HTTP server. * @param httpMethod An integer representing the HTTP method (e.g. GET, PUT) * used to communicate with server. + * @param version A String representing the version of the HTTP request, i.e. + * 1.0 or 1.1. * @return a new Request object representing the url * and httpMethod * @see org.apache.commons.latka.http.Request#HTTP_METHOD_GET * @see org.apache.commons.latka.http.Request#HTTP_METHOD_POST */ - public Request createRequest(URL url, int httpMethod) { + public Request createRequest(URL url, int httpMethod, String version) { // default label to null, follow redirects to true and proxy to null - return createRequest(null, url, httpMethod, true, null); + return createRequest(null, url, httpMethod, version, true, null); } /** - * Creates a request object with the specified URL and HTTP Method. Note: - * in the current implementation, old request objects will not + * Creates a labeled request object with the specified URL, HTTP Method, + * version, and redirect handling behavior. + * + * Note: in the current implementation, old request objects will not be resued. * * @param label Name of the request * @param url The URL to request of the HTTP server. * @param httpMethod An integer representing the HTTP method (e.g. GET, PUT) * used to communicate with server. + * @param version A String representing the version of the HTTP request, i.e. + * 1.0 or 1.1. * @param followRedirects whether HTTP redirects should be processed * @return a new Request object representing the url * and httpMethod @@ -130,18 +137,20 @@ * @see org.apache.commons.latka.http.Request#HTTP_METHOD_POST */ public Request createRequest(String label, URL url, int httpMethod, - boolean followRedirects) { + String version, boolean followRedirects) { // default proxy to null - return createRequest(label, url, httpMethod, followRedirects, null); + return createRequest(label, url, httpMethod, version, followRedirects, null); } /** - * Creates a request object with the specified URL and HTTP Method to be - * accessed via the provided proxy + * Creates a request object with the specified URL, HTTP Method, and + * version to be accessed via the provided proxy. * * @param url The URL to request of the HTTP server. * @param httpMethod An integer representing the HTTP method (e.g. GET, PUT) * used to communicate with server. + * @param version A String representing the version of the HTTP request, i.e. + * 1.0 or 1.1. * @return a new {@link Request} object representing the url * and httpMethod * @param proxy a proxy to use during the request @@ -149,19 +158,21 @@ * @see org.apache.commons.latka.http.Request#HTTP_METHOD_POST * @see org.apache.commons.latka.http.Proxy */ - public Request createRequest(URL url, int httpMethod, Proxy proxy) { + public Request createRequest(URL url, int httpMethod, Proxy proxy, String version) { // default label to null, and follow redirects to true - return createRequest(null, url, httpMethod, true, proxy); + return createRequest(null, url, httpMethod, version, true, proxy); } - /** Create a request with the given label, to access the given URL via the - * given HTTP method, and follow redirects as specified, using the given - * proxy for communications + /** + * Create a labeled request , with the specified URL, HTTP method, version, and + * redirect handling behavior, using the given proxy for communications. * * @param label a name used to identify the request * @param url The URL to request of the HTTP server. * @param httpMethod An integer representing the HTTP method (e.g. GET, PUT) * used to communicate with server. + * @param version A String representing the version of the HTTP request, i.e. + * 1.0 or 1.1. * @param followRedirects whether to follow HTTP redirection responses * @param proxy a proxy to use during the request * @return a new {@link Request} object representing the url @@ -171,11 +182,12 @@ * @see org.apache.commons.latka.http.Proxy */ public Request createRequest(String label, URL url, int httpMethod, - boolean followRedirects, Proxy proxy) { + String version, boolean followRedirects, Proxy proxy) { RequestImpl request = new RequestImpl(label, url, httpMethod, _state, this, followRedirects); request.setProxy(proxy); + request.setVersion(version); URL referer = getReferer(); -- To unsubscribe, e-mail: For additional commands, e-mail: