public interface HttpRequest
The following example illustrates the synchronous(blocking) invocation of a request:
HttpResponse response = request.invoke();
if (HttpResponse.OK == response.getResponseCode()) {
// handle the response
...
}
Asynchronous invocation of a request:
HttpResponse response = request.invoke(
new HttpResponseListener() {
public void handle(HttpResponse response) {
// handle the response
...
}
public void failed(Throwable exc) {
// handle the exception
//...
}
});
HttpResponseListener| Modifier and Type | Method and Description |
|---|---|
HttpRequestBuilder |
createBuilder()
Returns a new instance of
HttpRequestBuilder based on the request parameters. |
StreamedMessageBody |
getBody()
Returns the message body associated with this request.
|
java.lang.String |
getHeader(HttpHeader header)
Returns the value of
header for the request. |
HttpMessageHeaders |
getHeaders()
Returns an unmodifiable view of the HTTP headers and corresponding values.
|
HttpMethod |
getMethod()
Returns the HTTP method.
|
java.lang.String |
getURI()
Returns the string representation of URI.
|
boolean |
hasBody()
Returns
true if the request contains a message body. |
HttpResponse |
invoke()
Synchronously invoke the request.
|
void |
invoke(HttpResponseListener listener)
Asynchronously invoke the request with the given
listener. |
java.lang.String getURI()
HttpMethod getMethod()
java.lang.String getHeader(HttpHeader header)
header for the request.header - HTTP header.header is not present
then returned value is null.java.lang.NullPointerException - in case of header is null.HttpMessageHeaders getHeaders()
boolean hasBody()
true if the request contains a message body.true if the request contains a message body.StreamedMessageBody getBody()
null if the request does not contain a message body.HttpResponse invoke() throws HttpClientException
HttpResponse instance.HttpClientExceptionvoid invoke(HttpResponseListener listener)
listener.listener - invocation listener for asynchronous handling a response.java.lang.NullPointerException - in case of listener is null.HttpRequestBuilder createBuilder()
HttpRequestBuilder based on the request parameters.HttpRequestBuilder.Copyright © 2013, 2014, Oracle and/or its affiliates. All rights reserved.