public class HttpRequest extends Object implements Request
Request.BeginListener, Request.CommitListener, Request.ContentListener, Request.FailureListener, Request.HeadersListener, Request.Listener, Request.QueuedListener, Request.RequestListener, Request.SuccessListenerpublic HttpConversation getConversation()
public String getScheme()
public String getHost()
public int getPort()
public String getMethod()
public Request method(HttpMethod method)
public String getPath()
getPath in interface RequestRequest.getQuery()public Request path(String path)
RequestUTF-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, use Request.param(String, String).public String getQuery()
getQuery in interface RequestRequest.getPath(),
Request.getParams()public URI getURI()
public HttpVersion getVersion()
getVersion in interface Requestpublic Request version(HttpVersion version)
public Request param(String name, String value)
RequestUTF-8 URL encoded.public Fields getParams()
public String getAgent()
public Request header(String name, String value)
header in interface Requestname - the name of the headervalue - the value of the headerRequest.header(HttpHeader, String)public Request header(HttpHeader header, String value)
RequestAdds the given value to the specified header.
Multiple calls with the same parameters will add multiple values;
use the value null to remove the header completely.
public List<HttpCookie> getCookies()
getCookies in interface Requestpublic Request cookie(HttpCookie cookie)
public Request tag(Object tag)
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() and Object.equals(Object)
so that it can be used, along with the origin, to identify
a destination.
public Object getTag()
public Map<String,Object> getAttributes()
getAttributes in interface Requestpublic HttpFields getHeaders()
getHeaders in interface Requestpublic <T extends Request.RequestListener> List<T> getRequestListeners(Class<T> type)
getRequestListeners in interface RequestT - the type of listener classtype - the class of the listener, or null for all listeners classespublic Request listener(Request.Listener listener)
public Request onRequestQueued(Request.QueuedListener listener)
onRequestQueued in interface Requestlistener - a listener for request queued eventpublic Request onRequestBegin(Request.BeginListener listener)
onRequestBegin in interface Requestlistener - a listener for request begin eventpublic Request onRequestHeaders(Request.HeadersListener listener)
onRequestHeaders in interface Requestlistener - a listener for request headers eventpublic Request onRequestCommit(Request.CommitListener listener)
onRequestCommit in interface Requestlistener - a listener for request commit eventpublic Request onRequestContent(Request.ContentListener listener)
onRequestContent in interface Requestlistener - a listener for request content eventspublic Request onRequestSuccess(Request.SuccessListener listener)
onRequestSuccess in interface Requestlistener - a listener for request success eventpublic Request onRequestFailure(Request.FailureListener listener)
onRequestFailure in interface Requestlistener - a listener for request failure eventpublic Request onResponseBegin(Response.BeginListener listener)
onResponseBegin in interface Requestlistener - a listener for response begin eventpublic Request onResponseHeader(Response.HeaderListener listener)
onResponseHeader in interface Requestlistener - a listener for response header eventpublic Request onResponseHeaders(Response.HeadersListener listener)
onResponseHeaders in interface Requestlistener - a listener for response headers eventpublic Request onResponseContent(Response.ContentListener listener)
onResponseContent in interface Requestlistener - a consuming listener for response content eventspublic Request onResponseContentAsync(Response.AsyncContentListener listener)
onResponseContentAsync in interface Requestlistener - an asynchronous listener for response content eventspublic Request onResponseContentDemanded(Response.DemandedContentListener listener)
onResponseContentDemanded in interface Requestlistener - an asynchronous listener for response content eventspublic Request onResponseSuccess(Response.SuccessListener listener)
onResponseSuccess in interface Requestlistener - a listener for response success eventpublic Request onResponseFailure(Response.FailureListener listener)
onResponseFailure in interface Requestlistener - a listener for response failure eventpublic Request onComplete(Response.CompleteListener listener)
onComplete in interface Requestlistener - a listener for complete eventpublic Request pushListener(BiFunction<Request,Request,Response.CompleteListener> listener)
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 the BiFunction are this request and the
synthesized request for the pushed resource.
The BiFunction should return a CompleteListener that
may also implement other listener interfaces to be notified of various
response events, or null to signal that the pushed resource
should be canceled.
listener - a listener for pushed resource eventspublic HttpRequest trailers(Supplier<HttpFields> trailers)
public ContentProvider getContent()
getContent in interface Requestpublic Request content(ContentProvider content)
public Request content(ContentProvider content, String contentType)
public Request file(Path file) throws IOException
Requestfile in interface Requestfile - the file to uploadIOException - if the file does not exist or cannot be readpublic Request file(Path file, String contentType) throws IOException
Requestfile in interface Requestfile - the file to uploadcontentType - the content type of the fileIOException - if the file does not exist or cannot be readpublic boolean isFollowRedirects()
isFollowRedirects in interface Requestpublic Request followRedirects(boolean follow)
followRedirects in interface Requestfollow - whether this request follows redirectspublic long getIdleTimeout()
getIdleTimeout in interface Requestpublic Request idleTimeout(long timeout, TimeUnit unit)
idleTimeout in interface Requesttimeout - the idle timeout for this requestunit - the idle timeout unitpublic long getTimeout()
getTimeout in interface Requestpublic ContentResponse send() throws InterruptedException, TimeoutException, ExecutionException
RequestThis 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 own Response.Listener or a utility
listener such as InputStreamResponseListener.
The method returns when the complete event is fired.
send in interface RequestContentResponse for this requestInterruptedException - if send thread is interruptedTimeoutException - if send times outExecutionException - if execution failsResponse.CompleteListener.onComplete(Result)public void send(Response.CompleteListener listener)
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.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.
public BiFunction<Request,Request,Response.CompleteListener> getPushListener()
public Supplier<HttpFields> getTrailers()
public boolean abort(Throwable cause)
Requestpublic Throwable getAbortCause()
getAbortCause in interface RequestRequest.abort(Throwable),
or null if this request has not been abortedCopyright © 2010 - 2020 Adobe. All Rights Reserved