Request.Listener
Modifier | Constructor and Description |
---|---|
protected |
HttpRequest(HttpClient client,
long id,
URI uri) |
|
HttpRequest(HttpClient client,
URI uri) |
Modifier and Type | Method and Description |
---|---|
void |
abort()
Attempts to abort the send of this request.
|
boolean |
aborted() |
String |
agent() |
Request |
agent(String agent) |
Request |
attribute(String name,
Object value) |
Map<String,Object> |
attributes() |
ContentProvider |
content() |
Request |
content(ContentProvider content) |
long |
conversation() |
Request |
file(java.nio.file.Path file)
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,
String contentType)
Shortcut method to specify a file as a content for this request, with the given content type.
|
boolean |
followRedirects() |
Request |
followRedirects(boolean follow) |
Request |
header(String name,
String value) |
HttpFields |
headers() |
String |
host() |
long |
idleTimeout() |
Request |
idleTimeout(long timeout) |
Request.Listener |
listener() |
Request |
listener(Request.Listener listener) |
HttpMethod |
method() |
Request |
method(HttpMethod method) |
Request |
param(String name,
String value) |
Fields |
params() |
String |
path() |
Request |
path(String path) |
int |
port() |
String |
scheme() |
Request |
scheme(String scheme) |
Future<ContentResponse> |
send()
Sends this request and returns a
Future that can be used to wait for the
request and the response to be completed (either with a success or a failure). |
void |
send(Response.Listener listener)
Sends this request and asynchronously notifies the given listener for response events.
|
String |
toString() |
String |
uri() |
HttpVersion |
version() |
Request |
version(HttpVersion version) |
public HttpRequest(HttpClient client, URI uri)
protected HttpRequest(HttpClient client, long id, URI uri)
public long conversation()
conversation
in interface Request
public String scheme()
public String host()
public int port()
public HttpMethod method()
public Request method(HttpMethod method)
public String path()
public String uri()
public HttpVersion version()
public Request version(HttpVersion version)
public Fields params()
public String agent()
public Map<String,Object> attributes()
attributes
in interface Request
public HttpFields headers()
public Request.Listener listener()
public Request listener(Request.Listener listener)
public ContentProvider content()
public Request content(ContentProvider content)
public Request file(java.nio.file.Path file) throws IOException
Request
file
in interface Request
file
- the file to uploadIOException
- if the file does not exist or cannot be readpublic Request file(java.nio.file.Path file, String contentType) throws IOException
Request
file
in interface Request
file
- the file to uploadcontentType
- the content type of the fileIOException
- if the file does not exist or cannot be readpublic boolean followRedirects()
followRedirects
in interface Request
public Request followRedirects(boolean follow)
followRedirects
in interface Request
follow
- whether this request follows redirectspublic long idleTimeout()
idleTimeout
in interface Request
public Request idleTimeout(long timeout)
idleTimeout
in interface Request
timeout
- the idle timeout for this requestpublic Future<ContentResponse> send()
Request
Future
that can be used to wait for the
request and the response to be completed (either with a success or a failure).
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.Listener)
instead, passing your own Response.Listener
or a utility
listener such as InputStreamResponseListener
.
The future will return when Response.Listener.onComplete(Result)
is invoked.send
in interface Request
Future
to wait on for request and response completionResponse.Listener.onComplete(Result)
public void send(Response.Listener listener)
Request
public void abort()
Request
abort
in interface Request
Request.aborted()
public boolean aborted()
aborted
in interface Request
Request.abort()
was calledCopyright © 1995-2012 Mort Bay Consulting. All Rights Reserved.