- All Implemented Interfaces:
Request
- Direct Known Subclasses:
HttpProxy.TunnelRequest
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.eclipse.jetty.client.api.Request
Request.BeginListener, Request.CommitListener, Request.Content, Request.ContentListener, Request.FailureListener, Request.HeadersListener, Request.Listener, Request.QueuedListener, Request.RequestListener, Request.SuccessListener -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedHttpRequest(HttpClient client, HttpConversation conversation, URI uri) -
Method Summary
Modifier and TypeMethodDescriptionAttempts to abort the send of this request.addHeader(org.eclipse.jetty.http.HttpField header) body(Request.Content content) cookie(HttpCookie cookie) Shortcut method to specify a file as a content for this request, with the default content type of "application/octet-stream".Shortcut method to specify a file as a content for this request, with the given content type.followRedirects(boolean follow) getAgent()getBody()org.eclipse.jetty.http.HttpFieldsgetHost()longorg.eclipse.jetty.util.FieldsgetPath()intgetPort()getQuery()<T extends Request.RequestListener>
List<T>getRequestListeners(Class<T> type) protected List<Response.ResponseListener>getTag()longSupplier<org.eclipse.jetty.http.HttpFields>getURI()org.eclipse.jetty.http.HttpVersionModifies the headers of this request.idleTimeout(long timeout, TimeUnit unit) booleanbooleanlistener(Request.Listener listener) method(org.eclipse.jetty.http.HttpMethod method) onComplete(Response.CompleteListener listener) onPush(BiFunction<Request, Request, Response.CompleteListener> pushHandler) Sets a handler for pushed resources.onRequestBegin(Request.BeginListener listener) onRequestCommit(Request.CommitListener listener) onRequestContent(Request.ContentListener listener) onRequestFailure(Request.FailureListener listener) onRequestHeaders(Request.HeadersListener listener) onRequestQueued(Request.QueuedListener listener) onRequestSuccess(Request.SuccessListener listener) onResponseBegin(Response.BeginListener listener) onResponseContent(Response.ContentListener listener) onResponseFailure(Response.FailureListener listener) onResponseHeader(Response.HeaderListener listener) onResponseHeaders(Response.HeadersListener listener) onResponseSuccess(Response.SuccessListener listener) Adds a URI query parameter with the given name and value.Specifies the URI path - and possibly the query - of this request.port(int port) send()Sends this request and returns the response.voidsend(Response.CompleteListener listener) Sends this request and asynchronously notifies the given listener for response events.Tags this request with the given metadata tag.toString()trailersSupplier(Supplier<org.eclipse.jetty.http.HttpFields> trailers) Provides the trailers of this request.upgradeProtocol(String upgradeProtocol) version(org.eclipse.jetty.http.HttpVersion version)
-
Constructor Details
-
HttpRequest
-
-
Method Details
-
getConversation
-
getScheme
-
scheme
-
getHost
-
host
-
getPort
public int getPort() -
port
-
getMethod
-
method
-
method
-
getPath
-
path
Description copied from interface:RequestSpecifies 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, useRequest.param(String, String). -
getQuery
-
getURI
-
getVersion
public org.eclipse.jetty.http.HttpVersion getVersion()- Specified by:
getVersionin interfaceRequest- Returns:
- the HTTP version of this request, such as "HTTP/1.1"
-
isVersionExplicit
public boolean isVersionExplicit() -
version
-
param
Description copied from interface:RequestAdds a URI query parameter with the given name and value. The value isUTF-8 URL encoded. -
getParams
public org.eclipse.jetty.util.Fields getParams() -
getAgent
-
agent
-
accept
-
getCookies
- Specified by:
getCookiesin interfaceRequest- Returns:
- the cookies associated with this request
-
cookie
-
tag
Description copied from interface:RequestTags 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. -
getTag
-
attribute
-
getAttributes
- Specified by:
getAttributesin interfaceRequest- Returns:
- the attributes of this request
-
getHeaders
public org.eclipse.jetty.http.HttpFields getHeaders()- Specified by:
getHeadersin interfaceRequest- Returns:
- the headers of this request
-
headers
Description copied from interface:RequestModifies the headers of this request. -
addHeader
-
getRequestListeners
- Specified by:
getRequestListenersin interfaceRequest- Type Parameters:
T- the type of listener class- Parameters:
type- the class of the listener, or null for all listeners classes- Returns:
- the listeners for request events of the given class
-
listener
-
onRequestQueued
- Specified by:
onRequestQueuedin interfaceRequest- Parameters:
listener- a listener for request queued event- Returns:
- this request object
-
onRequestBegin
- Specified by:
onRequestBeginin interfaceRequest- Parameters:
listener- a listener for request begin event- Returns:
- this request object
-
onRequestHeaders
- Specified by:
onRequestHeadersin interfaceRequest- Parameters:
listener- a listener for request headers event- Returns:
- this request object
-
onRequestCommit
- Specified by:
onRequestCommitin interfaceRequest- Parameters:
listener- a listener for request commit event- Returns:
- this request object
-
onRequestContent
- Specified by:
onRequestContentin interfaceRequest- Parameters:
listener- a listener for request content events- Returns:
- this request object
-
onRequestSuccess
- Specified by:
onRequestSuccessin interfaceRequest- Parameters:
listener- a listener for request success event- Returns:
- this request object
-
onRequestFailure
- Specified by:
onRequestFailurein interfaceRequest- Parameters:
listener- a listener for request failure event- Returns:
- this request object
-
onResponseBegin
- Specified by:
onResponseBeginin interfaceRequest- Parameters:
listener- a listener for response begin event- Returns:
- this request object
-
onResponseHeader
- Specified by:
onResponseHeaderin interfaceRequest- Parameters:
listener- a listener for response header event- Returns:
- this request object
-
onResponseHeaders
- Specified by:
onResponseHeadersin interfaceRequest- Parameters:
listener- a listener for response headers event- Returns:
- this request object
-
onResponseContent
- Specified by:
onResponseContentin interfaceRequest- Parameters:
listener- a consuming listener for response content events- Returns:
- this request object
-
onResponseContentAsync
- Specified by:
onResponseContentAsyncin interfaceRequest- Parameters:
listener- an asynchronous listener for response content events- Returns:
- this request object
-
onResponseContentDemanded
- Specified by:
onResponseContentDemandedin interfaceRequest- Parameters:
listener- an asynchronous listener for response content events- Returns:
- this request object
-
onResponseContentSource
- Specified by:
onResponseContentSourcein interfaceRequest- Parameters:
listener- a listener for drivingContent.Source- Returns:
- this request object
-
onResponseSuccess
- Specified by:
onResponseSuccessin interfaceRequest- Parameters:
listener- a listener for response success event- Returns:
- this request object
-
onResponseFailure
- Specified by:
onResponseFailurein interfaceRequest- Parameters:
listener- a listener for response failure event- Returns:
- this request object
-
onPush
Description copied from interface:RequestSets a handler for pushed resources.
When resources are pushed from the server, the given
pushHandleris invoked for every pushed resource. The parameters to theBiFunctionare this request and the synthesized request for the pushed resource. TheBiFunctionshould return aCompleteListenerthat may also implement other listener interfaces to be notified of various response events, ornullto signal that the pushed resource should be canceled. -
onComplete
- Specified by:
onCompletein interfaceRequest- Parameters:
listener- a listener for complete event- Returns:
- this request object
-
trailersSupplier
Description copied from interface:RequestProvides the trailers of this request.- Specified by:
trailersSupplierin interfaceRequest- Parameters:
trailers- the supplier of the trailers of this request- Returns:
- this request object
-
upgradeProtocol
-
getBody
-
body
-
file
Description copied from interface:RequestShortcut method to specify a file as a content for this request, with the default content type of "application/octet-stream".- Specified by:
filein interfaceRequest- Parameters:
file- the file to upload- Returns:
- this request object
- Throws:
IOException- if the file does not exist or cannot be read
-
file
Description copied from interface:RequestShortcut method to specify a file as a content for this request, with the given content type.- Specified by:
filein interfaceRequest- 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
-
isFollowRedirects
public boolean isFollowRedirects()- Specified by:
isFollowRedirectsin interfaceRequest- Returns:
- whether this request follows redirects
-
followRedirects
- Specified by:
followRedirectsin interfaceRequest- Parameters:
follow- whether this request follows redirects- Returns:
- this request object
-
getIdleTimeout
public long getIdleTimeout()- Specified by:
getIdleTimeoutin interfaceRequest- Returns:
- the idle timeout for this request, in milliseconds
-
idleTimeout
- Specified by:
idleTimeoutin interfaceRequest- Parameters:
timeout- the idle timeout for this requestunit- the idle timeout unit- Returns:
- this request object
-
getTimeout
public long getTimeout()- Specified by:
getTimeoutin interfaceRequest- Returns:
- the total timeout for this request, in milliseconds; zero or negative if the timeout is disabled
-
timeout
-
send
Description copied from interface:RequestSends 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
Request.send(Response.CompleteListener)instead, passing your ownResponse.Listeneror a utility listener such asInputStreamResponseListener.The method returns when the
complete eventis fired.- Specified by:
sendin interfaceRequest- Returns:
- a
ContentResponsefor this request - Throws:
InterruptedException- if send thread is interruptedTimeoutException- if send times outExecutionException- if execution fails- See Also:
-
send
Description copied from interface:RequestSends 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.CompleteListenerbut 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. -
getResponseListeners
-
getPushHandler
-
getTrailersSupplier
- Specified by:
getTrailersSupplierin interfaceRequest- Returns:
- the supplier of the trailers of this request
-
getUpgradeProtocol
-
abort
Description copied from interface:RequestAttempts to abort the send of this request. -
getAbortCause
- Specified by:
getAbortCausein interfaceRequest- Returns:
- the abort cause passed to
Request.abort(Throwable), or null if this request has not been aborted
-
toString
-