Return-Path:
Delivered-To: apmail-jakarta-httpcomponents-commits-archive@www.apache.org
Received: (qmail 87871 invoked from network); 7 May 2007 20:08:54 -0000
Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2)
by minotaur.apache.org with SMTP; 7 May 2007 20:08:54 -0000
Received: (qmail 83109 invoked by uid 500); 7 May 2007 20:09:01 -0000
Delivered-To: apmail-jakarta-httpcomponents-commits-archive@jakarta.apache.org
Received: (qmail 83093 invoked by uid 500); 7 May 2007 20:09:01 -0000
Mailing-List: contact httpcomponents-commits-help@jakarta.apache.org;
run by ezmlm
Precedence: bulk
List-Help:
List-Unsubscribe:
List-Post:
List-Id:
Reply-To: httpcomponents-dev@jakarta.apache.org
Delivered-To: mailing list httpcomponents-commits@jakarta.apache.org
Received: (qmail 83083 invoked by uid 99); 7 May 2007 20:09:01 -0000
Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133)
by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 07 May 2007 13:09:01 -0700
X-ASF-Spam-Status: No, hits=-99.5 required=10.0
tests=ALL_TRUSTED,NO_REAL_NAME
X-Spam-Check-By: apache.org
Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3)
by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 07 May 2007 13:08:53 -0700
Received: by eris.apache.org (Postfix, from userid 65534)
id 20C361A9838; Mon, 7 May 2007 13:08:33 -0700 (PDT)
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: svn commit: r535975 - in
/jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http:
client/methods/HttpUriRequest.java client/protocol/RequestAddCookies.java
impl/client/RequestWrapper.java
Date: Mon, 07 May 2007 20:08:32 -0000
To: httpcomponents-commits@jakarta.apache.org
From: olegk@apache.org
X-Mailer: svnmailer-1.1.0
Message-Id: <20070507200833.20C361A9838@eris.apache.org>
X-Virus-Checked: Checked by ClamAV on apache.org
Author: olegk
Date: Mon May 7 13:08:31 2007
New Revision: 535975
URL: http://svn.apache.org/viewvc?view=rev&rev=535975
Log:
Changelog:
* Added an extended version of the HttpRequest interface that provides convenience methods to access request properties such as parsed request URI and method type.
* Added a wrapper class for HttpRequests that can be used to change properties of the current request without modifying the original request object.
Added:
jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/client/methods/HttpUriRequest.java (with props)
jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/impl/client/RequestWrapper.java (with props)
Modified:
jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/client/protocol/RequestAddCookies.java
Added: jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/client/methods/HttpUriRequest.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/client/methods/HttpUriRequest.java?view=auto&rev=535975
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/client/methods/HttpUriRequest.java (added)
+++ jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/client/methods/HttpUriRequest.java Mon May 7 13:08:31 2007
@@ -0,0 +1,59 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ *
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * .
+ *
+ */
+
+package org.apache.http.client.methods;
+
+import java.net.URI;
+
+import org.apache.http.HttpRequest;
+import org.apache.http.HttpVersion;
+
+/**
+ * Extended version of the {@link HttpRequest} interface that provides
+ * convenience methods to access request properties such as request URI
+ * and method type.
+ *
+ * @author Oleg Kalnichevski
+ *
+ *
+ * @version $Revision$
+ *
+ * @since 4.0
+ */
+public interface HttpUriRequest extends HttpRequest {
+
+ String getMethod();
+
+ HttpVersion getHttpVersion();
+
+ URI getURI();
+
+}
Propchange: jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/client/methods/HttpUriRequest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/client/methods/HttpUriRequest.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/client/methods/HttpUriRequest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/client/protocol/RequestAddCookies.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/client/protocol/RequestAddCookies.java?view=diff&rev=535975&r1=535974&r2=535975
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/client/protocol/RequestAddCookies.java (original)
+++ jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/client/protocol/RequestAddCookies.java Mon May 7 13:08:31 2007
@@ -46,6 +46,7 @@
import org.apache.http.HttpRequestInterceptor;
import org.apache.http.ProtocolException;
import org.apache.http.client.HttpState;
+import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.client.params.HttpClientParams;
import org.apache.http.conn.ManagedClientConnection;
import org.apache.http.cookie.Cookie;
@@ -119,11 +120,15 @@
}
URI requestURI;
- try {
- requestURI = new URI(request.getRequestLine().getUri());
- } catch (URISyntaxException ex) {
- throw new ProtocolException("Invalid request URI: " +
- request.getRequestLine().getUri(), ex);
+ if (request instanceof HttpUriRequest) {
+ requestURI = ((HttpUriRequest) request).getURI();
+ } else {
+ try {
+ requestURI = new URI(request.getRequestLine().getUri());
+ } catch (URISyntaxException ex) {
+ throw new ProtocolException("Invalid request URI: " +
+ request.getRequestLine().getUri(), ex);
+ }
}
CookieOrigin cookieOrigin = new CookieOrigin(
Added: jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/impl/client/RequestWrapper.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/impl/client/RequestWrapper.java?view=auto&rev=535975
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/impl/client/RequestWrapper.java (added)
+++ jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/impl/client/RequestWrapper.java Mon May 7 13:08:31 2007
@@ -0,0 +1,137 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ *
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * .
+ *
+ */
+
+package org.apache.http.impl.client;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.apache.http.HttpRequest;
+import org.apache.http.HttpVersion;
+import org.apache.http.RequestLine;
+import org.apache.http.client.methods.HttpUriRequest;
+import org.apache.http.message.AbstractHttpMessage;
+import org.apache.http.message.BasicRequestLine;
+import org.apache.http.params.HttpProtocolParams;
+
+/**
+ * A wrapper class for {@link HttpRequest}s that can be used to change
+ * properties of the current request without modifying the original
+ * object.
+ *
+ * This class is also capable of resetting the request headers to
+ * the state of the original request.
+ *
+ * @author Oleg Kalnichevski
+ *
+ * @version $Revision$
+ *
+ * @since 4.0
+ */
+class RequestWrapper extends AbstractHttpMessage implements HttpUriRequest {
+
+ private final HttpRequest original;
+
+ private URI uri;
+ private String method;
+ private HttpVersion version;
+
+ public RequestWrapper(final HttpRequest request) throws URISyntaxException {
+ super();
+ if (request == null) {
+ throw new IllegalArgumentException("HTTP request may not be null");
+ }
+ this.original = request;
+ // Make a copy of original headers
+ setHeaders(request.getAllHeaders());
+ setParams(request.getParams());
+ // Make a copy of the original URI
+ if (request instanceof HttpUriRequest) {
+ this.uri = ((HttpUriRequest) request).getURI();
+ this.method = ((HttpUriRequest) request).getMethod();
+ this.version = null;
+ } else {
+ RequestLine requestLine = request.getRequestLine();
+ this.uri = new URI(requestLine.getUri());
+ this.method = requestLine.getMethod();
+ this.version = request.getHttpVersion();
+ }
+ }
+
+ public String getMethod() {
+ return this.method;
+ }
+
+ public void setMethod(final String method) {
+ if (method == null) {
+ throw new IllegalArgumentException("Method name may not be null");
+ }
+ this.method = method;
+ }
+
+ public HttpVersion getHttpVersion() {
+ if (this.version != null) {
+ return this.version;
+ } else {
+ return HttpProtocolParams.getVersion(getParams());
+ }
+ }
+
+ public void setVersion(final HttpVersion version) {
+ this.version = version;
+ }
+
+ public URI getURI() {
+ return this.uri;
+ }
+
+ public void setURI(final URI uri) {
+ this.uri = uri;
+ }
+
+ public RequestLine getRequestLine() {
+ String method = getMethod();
+ HttpVersion ver = getHttpVersion();
+ URI uri = getURI();
+ String uritext;
+ if (uri != null) {
+ uritext = uri.toASCIIString();
+ } else {
+ uritext = "/";
+ }
+ return new BasicRequestLine(method, uritext, ver);
+ }
+
+ public void resetHeaders() {
+ setHeaders(this.original.getAllHeaders());
+ }
+
+}
Propchange: jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/impl/client/RequestWrapper.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/impl/client/RequestWrapper.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/impl/client/RequestWrapper.java
------------------------------------------------------------------------------
svn:mime-type = text/plain