Package org.apache.http.client.methods
Class HttpRequestWrapper
- java.lang.Object
-
- org.apache.http.message.AbstractHttpMessage
-
- org.apache.http.client.methods.HttpRequestWrapper
-
- All Implemented Interfaces:
HttpUriRequest
,org.apache.http.HttpMessage
,org.apache.http.HttpRequest
- Direct Known Subclasses:
HttpRequestWrapper.HttpEntityEnclosingRequestWrapper
public class HttpRequestWrapper extends org.apache.http.message.AbstractHttpMessage implements HttpUriRequest
A wrapper class forHttpRequest
that can be used to change properties of the current request without modifying the original object.- Since:
- 4.3
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
HttpRequestWrapper.HttpEntityEnclosingRequestWrapper
-
Constructor Summary
Constructors Modifier Constructor Description private
HttpRequestWrapper(org.apache.http.HttpRequest request, org.apache.http.HttpHost target)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
abort()
Aborts execution of the request.java.lang.String
getMethod()
Returns the HTTP method this request uses, such asGET
,PUT
,POST
, or other.org.apache.http.HttpRequest
getOriginal()
org.apache.http.params.HttpParams
getParams()
Deprecated.(4.3) useRequestConfig
.org.apache.http.ProtocolVersion
getProtocolVersion()
org.apache.http.RequestLine
getRequestLine()
org.apache.http.HttpHost
getTarget()
java.net.URI
getURI()
Returns the URI this request uses, such ashttp://example.org/path/to/file
.boolean
isAborted()
Tests if the request execution has been aborted.void
setProtocolVersion(org.apache.http.ProtocolVersion version)
void
setURI(java.net.URI uri)
java.lang.String
toString()
static HttpRequestWrapper
wrap(org.apache.http.HttpRequest request)
Creates a mutable wrapper of the original request.static HttpRequestWrapper
wrap(org.apache.http.HttpRequest request, org.apache.http.HttpHost target)
Creates a mutable wrapper of the original request.-
Methods inherited from class org.apache.http.message.AbstractHttpMessage
addHeader, addHeader, containsHeader, getAllHeaders, getFirstHeader, getHeaders, getLastHeader, headerIterator, headerIterator, removeHeader, removeHeaders, setHeader, setHeader, setHeaders, setParams
-
-
-
-
Field Detail
-
original
private final org.apache.http.HttpRequest original
-
target
private final org.apache.http.HttpHost target
-
method
private final java.lang.String method
-
requestLine
private org.apache.http.RequestLine requestLine
-
version
private org.apache.http.ProtocolVersion version
-
uri
private java.net.URI uri
-
-
Method Detail
-
getProtocolVersion
public org.apache.http.ProtocolVersion getProtocolVersion()
- Specified by:
getProtocolVersion
in interfaceorg.apache.http.HttpMessage
-
setProtocolVersion
public void setProtocolVersion(org.apache.http.ProtocolVersion version)
-
getURI
public java.net.URI getURI()
Description copied from interface:HttpUriRequest
Returns the URI this request uses, such ashttp://example.org/path/to/file
.Note that the URI may be absolute URI (as above) or may be a relative URI.
Implementations are encouraged to return the URI that was initially requested.
To find the final URI after any redirects have been processed, please see the section entitled HTTP execution context in the HttpClient Tutorial
- Specified by:
getURI
in interfaceHttpUriRequest
-
setURI
public void setURI(java.net.URI uri)
-
getMethod
public java.lang.String getMethod()
Description copied from interface:HttpUriRequest
Returns the HTTP method this request uses, such asGET
,PUT
,POST
, or other.- Specified by:
getMethod
in interfaceHttpUriRequest
-
abort
public void abort() throws java.lang.UnsupportedOperationException
Description copied from interface:HttpUriRequest
Aborts execution of the request.- Specified by:
abort
in interfaceHttpUriRequest
- Throws:
java.lang.UnsupportedOperationException
- if the abort operation is not supported / cannot be implemented.
-
isAborted
public boolean isAborted()
Description copied from interface:HttpUriRequest
Tests if the request execution has been aborted.- Specified by:
isAborted
in interfaceHttpUriRequest
- Returns:
true
if the request execution has been aborted,false
otherwise.
-
getRequestLine
public org.apache.http.RequestLine getRequestLine()
- Specified by:
getRequestLine
in interfaceorg.apache.http.HttpRequest
-
getOriginal
public org.apache.http.HttpRequest getOriginal()
-
getTarget
public org.apache.http.HttpHost getTarget()
- Since:
- 4.4
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
wrap
public static HttpRequestWrapper wrap(org.apache.http.HttpRequest request)
Creates a mutable wrapper of the original request.- Parameters:
request
- original request- Returns:
- mutable request wrappering the original one
-
wrap
public static HttpRequestWrapper wrap(org.apache.http.HttpRequest request, org.apache.http.HttpHost target)
Creates a mutable wrapper of the original request.- Parameters:
request
- original requesttarget
- original target, if explicitly specified- Returns:
- mutable request wrappering the original one
- Since:
- 4.4
-
getParams
@Deprecated public org.apache.http.params.HttpParams getParams()
Deprecated.(4.3) useRequestConfig
.- Specified by:
getParams
in interfaceorg.apache.http.HttpMessage
- Overrides:
getParams
in classorg.apache.http.message.AbstractHttpMessage
-
-