Interface Request
- All Known Implementing Classes:
HttpRequest
Request
represents an HTTP request, and offers a fluent interface to customize
various attributes such as the path, the headers, the content, etc.
You can create Request
objects via HttpClient.newRequest(String)
and
you can send them using either send()
for a blocking semantic, or
send(Response.CompleteListener)
for an asynchronous semantic.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interface
Deprecated.The Eclipse Jetty and Apache Felix Http Jetty packages are no longer supported.static interface
Deprecated.The Eclipse Jetty and Apache Felix Http Jetty packages are no longer supported.static interface
Deprecated.The Eclipse Jetty and Apache Felix Http Jetty packages are no longer supported.static interface
Deprecated.The Eclipse Jetty and Apache Felix Http Jetty packages are no longer supported.static interface
Deprecated.The Eclipse Jetty and Apache Felix Http Jetty packages are no longer supported.static interface
Deprecated.The Eclipse Jetty and Apache Felix Http Jetty packages are no longer supported.static interface
Deprecated.The Eclipse Jetty and Apache Felix Http Jetty packages are no longer supported.static interface
Deprecated.The Eclipse Jetty and Apache Felix Http Jetty packages are no longer supported.static interface
Deprecated.The Eclipse Jetty and Apache Felix Http Jetty packages are no longer supported. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Deprecated.Attempts to abort the send of this request.Deprecated.Deprecated.Deprecated.content
(ContentProvider content) Deprecated.content
(ContentProvider content, String contentType) Deprecated.cookie
(HttpCookie cookie) Deprecated.Deprecated.Shortcut method to specify a file as a content for this request, with the default content type of "application/octect-stream".Deprecated.Shortcut method to specify a file as a content for this request, with the given content type.followRedirects
(boolean follow) Deprecated.Deprecated.getAgent()
Deprecated.Deprecated.Deprecated.Deprecated.Deprecated.getHost()
Deprecated.long
Deprecated.Deprecated.Deprecated.getPath()
Deprecated.int
getPort()
Deprecated.getQuery()
Deprecated.<T extends Request.RequestListener>
List<T> getRequestListeners
(Class<T> listenerClass) Deprecated.Deprecated.getTag()
Deprecated.long
Deprecated.getURI()
Deprecated.Deprecated.Deprecated.header
(HttpHeader header, String value) Deprecated.Adds the givenvalue
to the specifiedheader
.default Request
Deprecated.idleTimeout
(long timeout, TimeUnit unit) Deprecated.boolean
Deprecated.listener
(Request.Listener listener) Deprecated.Deprecated.method
(HttpMethod method) Deprecated.onComplete
(Response.CompleteListener listener) Deprecated.onRequestBegin
(Request.BeginListener listener) Deprecated.onRequestCommit
(Request.CommitListener listener) Deprecated.onRequestContent
(Request.ContentListener listener) Deprecated.onRequestFailure
(Request.FailureListener listener) Deprecated.onRequestHeaders
(Request.HeadersListener listener) Deprecated.onRequestQueued
(Request.QueuedListener listener) Deprecated.onRequestSuccess
(Request.SuccessListener listener) Deprecated.onResponseBegin
(Response.BeginListener listener) Deprecated.onResponseContent
(Response.ContentListener listener) Deprecated.Deprecated.Deprecated.onResponseFailure
(Response.FailureListener listener) Deprecated.onResponseHeader
(Response.HeaderListener listener) Deprecated.onResponseHeaders
(Response.HeadersListener listener) Deprecated.onResponseSuccess
(Response.SuccessListener listener) Deprecated.Deprecated.Adds a URI query parameter with the given name and value.Deprecated.Specifies the URI path - and possibly the query - of this request.default Request
port
(int port) Deprecated.Deprecated.send()
Deprecated.Sends this request and returns the response.void
send
(Response.CompleteListener listener) Deprecated.Sends this request and asynchronously notifies the given listener for response events.Deprecated.Tags this request with the given metadata tag.Deprecated.version
(HttpVersion version) Deprecated.
-
Method Details
-
getScheme
String getScheme()Deprecated.- Returns:
- the URI scheme of this request, such as "http" or "https"
-
scheme
Deprecated.- Parameters:
scheme
- the URI scheme of this request, such as "http" or "https"- Returns:
- this request object
-
getHost
String getHost()Deprecated.- Returns:
- the URI host of this request, such as "127.0.0.1" or "google.com"
-
host
Deprecated.- Parameters:
host
- the URI host of this request, such as "127.0.0.1" or "google.com"- Returns:
- this request object
-
getPort
int getPort()Deprecated.- Returns:
- the URI port of this request such as 80 or 443
-
port
Deprecated.- Parameters:
port
- the URI port of this request such as 80 or 443- Returns:
- this request object
-
getMethod
String getMethod()Deprecated.- Returns:
- the method of this request, such as GET or POST, as a String
-
method
Deprecated.- Parameters:
method
- the method of this request, such as GET or POST- Returns:
- this request object
-
method
Deprecated.- Parameters:
method
- the method of this request, such as GET or POST- Returns:
- this request object
-
getPath
String getPath()Deprecated.- Returns:
- the URI path of this request, such as "/" or "/path" - without the query
- See Also:
-
path
Deprecated.Specifies the URI path - and possibly the query - of this request. If the query part is specified, parameter values must be properlyUTF-8 URL encoded
. For example, if the value for parameter "currency" is the euro symbol € then the query string for this parameter must be "currency=%E2%82%AC". For transparent encoding of parameter values, useparam(String, String)
.- Parameters:
path
- the URI path of this request, such as "/" or "/path?param=1"- Returns:
- this request object
-
getQuery
String getQuery()Deprecated.- Returns:
- the URI query string of this request such as "param=1"
- See Also:
-
getURI
URI getURI()Deprecated.- Returns:
- the full URI of this request such as "http://host:port/path?param=1"
-
getVersion
HttpVersion getVersion()Deprecated.- Returns:
- the HTTP version of this request, such as "HTTP/1.1"
-
version
Deprecated.- Parameters:
version
- the HTTP version of this request, such as "HTTP/1.1"- Returns:
- this request object
-
getParams
Fields getParams()Deprecated.- Returns:
- the URI query parameters of this request
-
param
Deprecated.Adds a URI query parameter with the given name and value. The value isUTF-8 URL encoded
.- Parameters:
name
- the name of the query parametervalue
- the value of the query parameter- Returns:
- this request object
-
getHeaders
HttpFields getHeaders()Deprecated.- Returns:
- the headers of this request
-
header
Deprecated.- Parameters:
name
- the name of the headervalue
- the value of the header- Returns:
- this request object
- See Also:
-
header
Deprecated.Adds the given
value
to the specifiedheader
.Multiple calls with the same parameters will add multiple values; use the value
null
to remove the header completely.- Parameters:
header
- the header namevalue
- the value of the header- Returns:
- this request object
-
getCookies
List<HttpCookie> getCookies()Deprecated.- Returns:
- the cookies associated with this request
-
cookie
Deprecated.- Parameters:
cookie
- a cookie for this request- Returns:
- this request object
-
tag
Deprecated.Tags this request with the given metadata tag.
Each different tag will create a different destination, even if the destination origin is the same.
This is particularly useful in proxies, where requests for the same origin but from different clients may be tagged with client's metadata (e.g. the client remote address).
The tag metadata class must correctly implement
Object.hashCode()
andObject.equals(Object)
so that it can be used, along with the origin, to identify a destination.- Parameters:
tag
- the metadata to tag the request with- Returns:
- this request object
-
getTag
Object getTag()Deprecated.- Returns:
- the metadata this request has been tagged with
-
attribute
Deprecated.- Parameters:
name
- the name of the attributevalue
- the value of the attribute- Returns:
- this request object
-
getAttributes
Deprecated.- Returns:
- the attributes of this request
-
getContent
ContentProvider getContent()Deprecated.- Returns:
- the content provider of this request
-
content
Deprecated.- Parameters:
content
- the content provider of this request- Returns:
- this request object
-
content
Deprecated.- Parameters:
content
- the content provider of this requestcontentType
- the content type- Returns:
- this request object
-
file
Deprecated.Shortcut method to specify a file as a content for this request, with the default content type of "application/octect-stream".- Parameters:
file
- the file to upload- Returns:
- this request object
- Throws:
IOException
- if the file does not exist or cannot be read
-
file
Deprecated.Shortcut method to specify a file as a content for this request, with the given content type.- Parameters:
file
- the file to uploadcontentType
- the content type of the file- Returns:
- this request object
- Throws:
IOException
- if the file does not exist or cannot be read
-
getAgent
String getAgent()Deprecated.- Returns:
- the user agent for this request
-
agent
Deprecated.- Parameters:
agent
- the user agent for this request (corresponds to theUser-Agent
header)- Returns:
- this request object
-
accept
Deprecated.- Parameters:
accepts
- the media types that are acceptable in the response, such as "text/plain;q=0.5" or "text/html" (corresponds to theAccept
header)- Returns:
- this request object
-
getIdleTimeout
long getIdleTimeout()Deprecated.- Returns:
- the idle timeout for this request, in milliseconds
-
idleTimeout
Deprecated.- Parameters:
timeout
- the idle timeout for this requestunit
- the idle timeout unit- Returns:
- this request object
-
getTimeout
long getTimeout()Deprecated.- Returns:
- the total timeout for this request, in milliseconds; zero or negative if the timeout is disabled
-
timeout
Deprecated.- Parameters:
timeout
- the total timeout for the request/response conversation; use zero or a negative value to disable the timeoutunit
- the timeout unit- Returns:
- this request object
-
isFollowRedirects
boolean isFollowRedirects()Deprecated.- Returns:
- whether this request follows redirects
-
followRedirects
Deprecated.- Parameters:
follow
- whether this request follows redirects- Returns:
- this request object
-
getRequestListeners
Deprecated.- Type Parameters:
T
- the type of listener class- Parameters:
listenerClass
- the class of the listener, or null for all listeners classes- Returns:
- the listeners for request events of the given class
-
listener
Deprecated.- Parameters:
listener
- a listener for request events- Returns:
- this request object
-
onRequestQueued
Deprecated.- Parameters:
listener
- a listener for request queued event- Returns:
- this request object
-
onRequestBegin
Deprecated.- Parameters:
listener
- a listener for request begin event- Returns:
- this request object
-
onRequestHeaders
Deprecated.- Parameters:
listener
- a listener for request headers event- Returns:
- this request object
-
onRequestCommit
Deprecated.- Parameters:
listener
- a listener for request commit event- Returns:
- this request object
-
onRequestContent
Deprecated.- Parameters:
listener
- a listener for request content events- Returns:
- this request object
-
onRequestSuccess
Deprecated.- Parameters:
listener
- a listener for request success event- Returns:
- this request object
-
onRequestFailure
Deprecated.- Parameters:
listener
- a listener for request failure event- Returns:
- this request object
-
onResponseBegin
Deprecated.- Parameters:
listener
- a listener for response begin event- Returns:
- this request object
-
onResponseHeader
Deprecated.- Parameters:
listener
- a listener for response header event- Returns:
- this request object
-
onResponseHeaders
Deprecated.- Parameters:
listener
- a listener for response headers event- Returns:
- this request object
-
onResponseContent
Deprecated.- Parameters:
listener
- a consuming listener for response content events- Returns:
- this request object
-
onResponseContentAsync
Deprecated.- Parameters:
listener
- an asynchronous listener for response content events- Returns:
- this request object
-
onResponseContentDemanded
Deprecated.- Parameters:
listener
- an asynchronous listener for response content events- Returns:
- this request object
-
onResponseSuccess
Deprecated.- Parameters:
listener
- a listener for response success event- Returns:
- this request object
-
onResponseFailure
Deprecated.- Parameters:
listener
- a listener for response failure event- Returns:
- this request object
-
onComplete
Deprecated.- Parameters:
listener
- a listener for complete event- Returns:
- this request object
-
send
Deprecated.Sends this request and returns the response.This method should be used when a simple blocking semantic is needed, and when it is known that the response content can be buffered without exceeding memory constraints.
For example, this method is not appropriate to download big files from a server; consider using
send(Response.CompleteListener)
instead, passing your ownResponse.Listener
or a utility listener such asInputStreamResponseListener
.The method returns when the
complete event
is fired.- Returns:
- a
ContentResponse
for this request - Throws:
InterruptedException
- if send thread is interruptedTimeoutException
- if send times outExecutionException
- if execution fails- See Also:
-
send
Deprecated.Sends this request and asynchronously notifies the given listener for response events.
This method should be used when the application needs to be notified of the various response events as they happen, or when the application needs to efficiently manage the response content.
The listener passed to this method may implement not only
Response.CompleteListener
but also other response listener interfaces, and all the events implemented will be notified. This allows application code to write a single listener class to handle all relevant events.- Parameters:
listener
- the listener that receives response events
-
abort
Deprecated.Attempts to abort the send of this request.- Parameters:
cause
- the abort cause, must not be null- Returns:
- whether the abort succeeded
-
getAbortCause
Throwable getAbortCause()Deprecated.- Returns:
- the abort cause passed to
abort(Throwable)
, or null if this request has not been aborted
-