You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2015/06/04 09:38:42 UTC
svn commit: r1683475 -
/httpcomponents/httpclient/branches/4.5.x/httpclient/src/main/java/org/apache/http/client/methods/HttpRequestWrapper.java
Author: olegk
Date: Thu Jun 4 07:38:42 2015
New Revision: 1683475
URL: http://svn.apache.org/r1683475
Log:
Cache request line in HttpRequestWrapper
Contributed by Dmitry Potapov <dpotapov at yandex-team.ru>
Modified:
httpcomponents/httpclient/branches/4.5.x/httpclient/src/main/java/org/apache/http/client/methods/HttpRequestWrapper.java
Modified: httpcomponents/httpclient/branches/4.5.x/httpclient/src/main/java/org/apache/http/client/methods/HttpRequestWrapper.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/4.5.x/httpclient/src/main/java/org/apache/http/client/methods/HttpRequestWrapper.java?rev=1683475&r1=1683474&r2=1683475&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/4.5.x/httpclient/src/main/java/org/apache/http/client/methods/HttpRequestWrapper.java (original)
+++ httpcomponents/httpclient/branches/4.5.x/httpclient/src/main/java/org/apache/http/client/methods/HttpRequestWrapper.java Thu Jun 4 07:38:42 2015
@@ -56,6 +56,7 @@ public class HttpRequestWrapper extends
private final HttpRequest original;
private final HttpHost target;
private final String method;
+ private RequestLine requestLine;
private ProtocolVersion version;
private URI uri;
@@ -80,6 +81,7 @@ public class HttpRequestWrapper extends
public void setProtocolVersion(final ProtocolVersion version) {
this.version = version;
+ this.requestLine = null;
}
@Override
@@ -89,6 +91,7 @@ public class HttpRequestWrapper extends
public void setURI(final URI uri) {
this.uri = uri;
+ this.requestLine = null;
}
@Override
@@ -108,16 +111,19 @@ public class HttpRequestWrapper extends
@Override
public RequestLine getRequestLine() {
- String requestUri = null;
- if (this.uri != null) {
- requestUri = this.uri.toASCIIString();
- } else {
- requestUri = this.original.getRequestLine().getUri();
- }
- if (requestUri == null || requestUri.isEmpty()) {
- requestUri = "/";
+ if (this.requestLine == null) {
+ String requestUri;
+ if (this.uri != null) {
+ requestUri = this.uri.toASCIIString();
+ } else {
+ requestUri = this.original.getRequestLine().getUri();
+ }
+ if (requestUri == null || requestUri.isEmpty()) {
+ requestUri = "/";
+ }
+ this.requestLine = new BasicRequestLine(this.method, requestUri, getProtocolVersion());
}
- return new BasicRequestLine(this.method, requestUri, getProtocolVersion());
+ return this.requestLine;
}
public HttpRequest getOriginal() {