415047 - Create URIs lazily in HttpClient.
URIs are now created lazily, although a call to Request.getURI() is made anyway for each request sending (and therefore the URI is created anyway for each send). However, we save creating multiple URIs in case the scheme, path, query or params are changed before sending the request.
This commit is contained in:
parent
73f06c2a14
commit
e65f21634d
|
@ -90,7 +90,6 @@ public class HttpRequest implements Request
|
||||||
path = uri.getRawPath();
|
path = uri.getRawPath();
|
||||||
query = uri.getRawQuery();
|
query = uri.getRawQuery();
|
||||||
extractParams(query);
|
extractParams(query);
|
||||||
this.uri = buildURI(true);
|
|
||||||
followRedirects(client.isFollowRedirects());
|
followRedirects(client.isFollowRedirects());
|
||||||
idleTimeout = client.getIdleTimeout();
|
idleTimeout = client.getIdleTimeout();
|
||||||
HttpField acceptEncodingField = client.getAcceptEncodingField();
|
HttpField acceptEncodingField = client.getAcceptEncodingField();
|
||||||
|
@ -115,7 +114,7 @@ public class HttpRequest implements Request
|
||||||
public Request scheme(String scheme)
|
public Request scheme(String scheme)
|
||||||
{
|
{
|
||||||
this.scheme = scheme;
|
this.scheme = scheme;
|
||||||
this.uri = buildURI(true);
|
this.uri = null;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,9 +172,9 @@ public class HttpRequest implements Request
|
||||||
params.clear();
|
params.clear();
|
||||||
extractParams(query);
|
extractParams(query);
|
||||||
}
|
}
|
||||||
this.uri = buildURI(true);
|
|
||||||
if (uri.isAbsolute())
|
if (uri.isAbsolute())
|
||||||
this.path = buildURI(false).toString();
|
this.path = buildURI(false).toString();
|
||||||
|
this.uri = null;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,7 +187,9 @@ public class HttpRequest implements Request
|
||||||
@Override
|
@Override
|
||||||
public URI getURI()
|
public URI getURI()
|
||||||
{
|
{
|
||||||
return uri;
|
if (uri != null)
|
||||||
|
return uri;
|
||||||
|
return uri = buildURI(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -209,7 +210,7 @@ public class HttpRequest implements Request
|
||||||
{
|
{
|
||||||
params.add(name, value);
|
params.add(name, value);
|
||||||
this.query = buildQuery();
|
this.query = buildQuery();
|
||||||
this.uri = buildURI(true);
|
this.uri = null;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -272,6 +273,7 @@ public class HttpRequest implements Request
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public <T extends RequestListener> List<T> getRequestListeners(Class<T> type)
|
public <T extends RequestListener> List<T> getRequestListeners(Class<T> type)
|
||||||
{
|
{
|
||||||
// This method is invoked often in a request/response conversation,
|
// This method is invoked often in a request/response conversation,
|
||||||
|
|
Loading…
Reference in New Issue