Class HttpRequest
- java.lang.Object
-
- org.eclipse.jetty.client.HttpRequest
-
- All Implemented Interfaces:
Request
- Direct Known Subclasses:
WebSocketUpgradeRequest
@Deprecated(since="2021-05-27") public class HttpRequest extends java.lang.Object implements Request
Deprecated.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.client.api.Request
Request.BeginListener, Request.CommitListener, Request.ContentListener, Request.FailureListener, Request.HeadersListener, Request.Listener, Request.QueuedListener, Request.RequestListener, Request.SuccessListener
-
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description boolean
abort(java.lang.Throwable cause)
Deprecated.Attempts to abort the send of this request.Request
accept(java.lang.String... accepts)
Deprecated.Request
agent(java.lang.String agent)
Deprecated.Request
attribute(java.lang.String name, java.lang.Object value)
Deprecated.Request
content(ContentProvider content)
Deprecated.Request
content(ContentProvider content, java.lang.String contentType)
Deprecated.Request
cookie(java.net.HttpCookie cookie)
Deprecated.Request
file(java.nio.file.Path file)
Deprecated.Shortcut method to specify a file as a content for this request, with the default content type of "application/octect-stream".Request
file(java.nio.file.Path file, java.lang.String contentType)
Deprecated.Shortcut method to specify a file as a content for this request, with the given content type.Request
followRedirects(boolean follow)
Deprecated.java.lang.Throwable
getAbortCause()
Deprecated.java.lang.String
getAgent()
Deprecated.java.util.Map<java.lang.String,java.lang.Object>
getAttributes()
Deprecated.ContentProvider
getContent()
Deprecated.HttpConversation
getConversation()
Deprecated.java.util.List<java.net.HttpCookie>
getCookies()
Deprecated.HttpFields
getHeaders()
Deprecated.java.lang.String
getHost()
Deprecated.long
getIdleTimeout()
Deprecated.java.lang.String
getMethod()
Deprecated.Fields
getParams()
Deprecated.java.lang.String
getPath()
Deprecated.int
getPort()
Deprecated.java.util.function.BiFunction<Request,Request,Response.CompleteListener>
getPushListener()
Deprecated.java.lang.String
getQuery()
Deprecated.<T extends Request.RequestListener>
java.util.List<T>getRequestListeners(java.lang.Class<T> type)
Deprecated.java.lang.String
getScheme()
Deprecated.java.lang.Object
getTag()
Deprecated.long
getTimeout()
Deprecated.java.util.function.Supplier<HttpFields>
getTrailers()
Deprecated.java.net.URI
getURI()
Deprecated.HttpVersion
getVersion()
Deprecated.Request
header(java.lang.String name, java.lang.String value)
Deprecated.Request
header(HttpHeader header, java.lang.String value)
Deprecated.Adds the givenvalue
to the specifiedheader
.Request
host(java.lang.String host)
Deprecated.Request
idleTimeout(long timeout, java.util.concurrent.TimeUnit unit)
Deprecated.boolean
isFollowRedirects()
Deprecated.Request
listener(Request.Listener listener)
Deprecated.Request
method(java.lang.String method)
Deprecated.Request
method(HttpMethod method)
Deprecated.Request
onComplete(Response.CompleteListener listener)
Deprecated.Request
onRequestBegin(Request.BeginListener listener)
Deprecated.Request
onRequestCommit(Request.CommitListener listener)
Deprecated.Request
onRequestContent(Request.ContentListener listener)
Deprecated.Request
onRequestFailure(Request.FailureListener listener)
Deprecated.Request
onRequestHeaders(Request.HeadersListener listener)
Deprecated.Request
onRequestQueued(Request.QueuedListener listener)
Deprecated.Request
onRequestSuccess(Request.SuccessListener listener)
Deprecated.Request
onResponseBegin(Response.BeginListener listener)
Deprecated.Request
onResponseContent(Response.ContentListener listener)
Deprecated.Request
onResponseContentAsync(Response.AsyncContentListener listener)
Deprecated.Request
onResponseContentDemanded(Response.DemandedContentListener listener)
Deprecated.Request
onResponseFailure(Response.FailureListener listener)
Deprecated.Request
onResponseHeader(Response.HeaderListener listener)
Deprecated.Request
onResponseHeaders(Response.HeadersListener listener)
Deprecated.Request
onResponseSuccess(Response.SuccessListener listener)
Deprecated.Request
param(java.lang.String name, java.lang.String value)
Deprecated.Adds a URI query parameter with the given name and value.Request
path(java.lang.String path)
Deprecated.Specifies the URI path - and possibly the query - of this request.Request
port(int port)
Deprecated.Request
pushListener(java.util.function.BiFunction<Request,Request,Response.CompleteListener> listener)
Deprecated.Sets a listener for pushed resources.Request
scheme(java.lang.String scheme)
Deprecated.ContentResponse
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.Request
tag(java.lang.Object tag)
Deprecated.Tags this request with the given metadata tag.Request
timeout(long timeout, java.util.concurrent.TimeUnit unit)
Deprecated.java.lang.String
toString()
Deprecated.HttpRequest
trailers(java.util.function.Supplier<HttpFields> trailers)
Deprecated.Request
version(HttpVersion version)
Deprecated.
-
-
-
Method Detail
-
getConversation
public HttpConversation getConversation()
Deprecated.
-
getScheme
public java.lang.String getScheme()
Deprecated.
-
scheme
public Request scheme(java.lang.String scheme)
Deprecated.
-
getHost
public java.lang.String getHost()
Deprecated.
-
host
public Request host(java.lang.String host)
Deprecated.
-
getPort
public int getPort()
Deprecated.
-
port
public Request port(int port)
Deprecated.
-
getMethod
public java.lang.String getMethod()
Deprecated.
-
method
public Request method(HttpMethod method)
Deprecated.
-
method
public Request method(java.lang.String method)
Deprecated.
-
getPath
public java.lang.String getPath()
Deprecated.- Specified by:
getPath
in interfaceRequest
- Returns:
- the URI path of this request, such as "/" or "/path" - without the query
- See Also:
Request.getQuery()
-
path
public Request path(java.lang.String path)
Deprecated.Description copied from interface:Request
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, useRequest.param(String, String)
.
-
getQuery
public java.lang.String getQuery()
Deprecated.- Specified by:
getQuery
in interfaceRequest
- Returns:
- the URI query string of this request such as "param=1"
- See Also:
Request.getPath()
,Request.getParams()
-
getURI
public java.net.URI getURI()
Deprecated.
-
getVersion
public HttpVersion getVersion()
Deprecated.- Specified by:
getVersion
in interfaceRequest
- Returns:
- the HTTP version of this request, such as "HTTP/1.1"
-
version
public Request version(HttpVersion version)
Deprecated.
-
param
public Request param(java.lang.String name, java.lang.String value)
Deprecated.Description copied from interface:Request
Adds a URI query parameter with the given name and value. The value isUTF-8 URL encoded
.
-
getParams
public Fields getParams()
Deprecated.
-
getAgent
public java.lang.String getAgent()
Deprecated.
-
agent
public Request agent(java.lang.String agent)
Deprecated.
-
accept
public Request accept(java.lang.String... accepts)
Deprecated.
-
header
public Request header(java.lang.String name, java.lang.String value)
Deprecated.- Specified by:
header
in interfaceRequest
- Parameters:
name
- the name of the headervalue
- the value of the header- Returns:
- this request object
- See Also:
Request.header(HttpHeader, String)
-
header
public Request header(HttpHeader header, java.lang.String value)
Deprecated.Description copied from interface:Request
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.
-
getCookies
public java.util.List<java.net.HttpCookie> getCookies()
Deprecated.- Specified by:
getCookies
in interfaceRequest
- Returns:
- the cookies associated with this request
-
cookie
public Request cookie(java.net.HttpCookie cookie)
Deprecated.
-
tag
public Request tag(java.lang.Object tag)
Deprecated.Description copied from interface:Request
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.
-
getTag
public java.lang.Object getTag()
Deprecated.
-
attribute
public Request attribute(java.lang.String name, java.lang.Object value)
Deprecated.
-
getAttributes
public java.util.Map<java.lang.String,java.lang.Object> getAttributes()
Deprecated.- Specified by:
getAttributes
in interfaceRequest
- Returns:
- the attributes of this request
-
getHeaders
public HttpFields getHeaders()
Deprecated.- Specified by:
getHeaders
in interfaceRequest
- Returns:
- the headers of this request
-
getRequestListeners
public <T extends Request.RequestListener> java.util.List<T> getRequestListeners(java.lang.Class<T> type)
Deprecated.- Specified by:
getRequestListeners
in 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
public Request listener(Request.Listener listener)
Deprecated.
-
onRequestQueued
public Request onRequestQueued(Request.QueuedListener listener)
Deprecated.- Specified by:
onRequestQueued
in interfaceRequest
- Parameters:
listener
- a listener for request queued event- Returns:
- this request object
-
onRequestBegin
public Request onRequestBegin(Request.BeginListener listener)
Deprecated.- Specified by:
onRequestBegin
in interfaceRequest
- Parameters:
listener
- a listener for request begin event- Returns:
- this request object
-
onRequestHeaders
public Request onRequestHeaders(Request.HeadersListener listener)
Deprecated.- Specified by:
onRequestHeaders
in interfaceRequest
- Parameters:
listener
- a listener for request headers event- Returns:
- this request object
-
onRequestCommit
public Request onRequestCommit(Request.CommitListener listener)
Deprecated.- Specified by:
onRequestCommit
in interfaceRequest
- Parameters:
listener
- a listener for request commit event- Returns:
- this request object
-
onRequestContent
public Request onRequestContent(Request.ContentListener listener)
Deprecated.- Specified by:
onRequestContent
in interfaceRequest
- Parameters:
listener
- a listener for request content events- Returns:
- this request object
-
onRequestSuccess
public Request onRequestSuccess(Request.SuccessListener listener)
Deprecated.- Specified by:
onRequestSuccess
in interfaceRequest
- Parameters:
listener
- a listener for request success event- Returns:
- this request object
-
onRequestFailure
public Request onRequestFailure(Request.FailureListener listener)
Deprecated.- Specified by:
onRequestFailure
in interfaceRequest
- Parameters:
listener
- a listener for request failure event- Returns:
- this request object
-
onResponseBegin
public Request onResponseBegin(Response.BeginListener listener)
Deprecated.- Specified by:
onResponseBegin
in interfaceRequest
- Parameters:
listener
- a listener for response begin event- Returns:
- this request object
-
onResponseHeader
public Request onResponseHeader(Response.HeaderListener listener)
Deprecated.- Specified by:
onResponseHeader
in interfaceRequest
- Parameters:
listener
- a listener for response header event- Returns:
- this request object
-
onResponseHeaders
public Request onResponseHeaders(Response.HeadersListener listener)
Deprecated.- Specified by:
onResponseHeaders
in interfaceRequest
- Parameters:
listener
- a listener for response headers event- Returns:
- this request object
-
onResponseContent
public Request onResponseContent(Response.ContentListener listener)
Deprecated.- Specified by:
onResponseContent
in interfaceRequest
- Parameters:
listener
- a consuming listener for response content events- Returns:
- this request object
-
onResponseContentAsync
public Request onResponseContentAsync(Response.AsyncContentListener listener)
Deprecated.- Specified by:
onResponseContentAsync
in interfaceRequest
- Parameters:
listener
- an asynchronous listener for response content events- Returns:
- this request object
-
onResponseContentDemanded
public Request onResponseContentDemanded(Response.DemandedContentListener listener)
Deprecated.- Specified by:
onResponseContentDemanded
in interfaceRequest
- Parameters:
listener
- an asynchronous listener for response content events- Returns:
- this request object
-
onResponseSuccess
public Request onResponseSuccess(Response.SuccessListener listener)
Deprecated.- Specified by:
onResponseSuccess
in interfaceRequest
- Parameters:
listener
- a listener for response success event- Returns:
- this request object
-
onResponseFailure
public Request onResponseFailure(Response.FailureListener listener)
Deprecated.- Specified by:
onResponseFailure
in interfaceRequest
- Parameters:
listener
- a listener for response failure event- Returns:
- this request object
-
onComplete
public Request onComplete(Response.CompleteListener listener)
Deprecated.- Specified by:
onComplete
in interfaceRequest
- Parameters:
listener
- a listener for complete event- Returns:
- this request object
-
pushListener
public Request pushListener(java.util.function.BiFunction<Request,Request,Response.CompleteListener> listener)
Deprecated.Sets a listener for pushed resources.
When resources are pushed from the server, the given
listener
is invoked for every pushed resource. The parameters to theBiFunction
are this request and the synthesized request for the pushed resource. TheBiFunction
should return aCompleteListener
that may also implement other listener interfaces to be notified of various response events, ornull
to signal that the pushed resource should be canceled.- Parameters:
listener
- a listener for pushed resource events- Returns:
- this request object
-
trailers
public HttpRequest trailers(java.util.function.Supplier<HttpFields> trailers)
Deprecated.
-
getContent
public ContentProvider getContent()
Deprecated.- Specified by:
getContent
in interfaceRequest
- Returns:
- the content provider of this request
-
content
public Request content(ContentProvider content)
Deprecated.
-
content
public Request content(ContentProvider content, java.lang.String contentType)
Deprecated.
-
file
public Request file(java.nio.file.Path file) throws java.io.IOException
Deprecated.Description copied from interface:Request
Shortcut method to specify a file as a content for this request, with the default content type of "application/octect-stream".
-
file
public Request file(java.nio.file.Path file, java.lang.String contentType) throws java.io.IOException
Deprecated.Description copied from interface:Request
Shortcut method to specify a file as a content for this request, with the given content type.
-
isFollowRedirects
public boolean isFollowRedirects()
Deprecated.- Specified by:
isFollowRedirects
in interfaceRequest
- Returns:
- whether this request follows redirects
-
followRedirects
public Request followRedirects(boolean follow)
Deprecated.- Specified by:
followRedirects
in interfaceRequest
- Parameters:
follow
- whether this request follows redirects- Returns:
- this request object
-
getIdleTimeout
public long getIdleTimeout()
Deprecated.- Specified by:
getIdleTimeout
in interfaceRequest
- Returns:
- the idle timeout for this request, in milliseconds
-
idleTimeout
public Request idleTimeout(long timeout, java.util.concurrent.TimeUnit unit)
Deprecated.- Specified by:
idleTimeout
in interfaceRequest
- Parameters:
timeout
- the idle timeout for this requestunit
- the idle timeout unit- Returns:
- this request object
-
getTimeout
public long getTimeout()
Deprecated.- Specified by:
getTimeout
in interfaceRequest
- Returns:
- the total timeout for this request, in milliseconds; zero or negative if the timeout is disabled
-
timeout
public Request timeout(long timeout, java.util.concurrent.TimeUnit unit)
Deprecated.
-
send
public ContentResponse send() throws java.lang.InterruptedException, java.util.concurrent.TimeoutException, java.util.concurrent.ExecutionException
Deprecated.Description copied from interface:Request
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
Request.send(Response.CompleteListener)
instead, passing your ownResponse.Listener
or a utility listener such asInputStreamResponseListener
.The method returns when the
complete event
is fired.- Specified by:
send
in interfaceRequest
- Returns:
- a
ContentResponse
for this request - Throws:
java.lang.InterruptedException
- if send thread is interruptedjava.util.concurrent.TimeoutException
- if send times outjava.util.concurrent.ExecutionException
- if execution fails- See Also:
Response.CompleteListener.onComplete(Result)
-
send
public void send(Response.CompleteListener listener)
Deprecated.Description copied from interface:Request
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.
-
getPushListener
public java.util.function.BiFunction<Request,Request,Response.CompleteListener> getPushListener()
Deprecated.
-
getTrailers
public java.util.function.Supplier<HttpFields> getTrailers()
Deprecated.
-
abort
public boolean abort(java.lang.Throwable cause)
Deprecated.Description copied from interface:Request
Attempts to abort the send of this request.
-
getAbortCause
public java.lang.Throwable getAbortCause()
Deprecated.- Specified by:
getAbortCause
in interfaceRequest
- Returns:
- the abort cause passed to
Request.abort(Throwable)
, or null if this request has not been aborted
-
toString
public java.lang.String toString()
Deprecated.- Overrides:
toString
in classjava.lang.Object
-
-