java.lang.Object | |
↳ | chan.http.HttpRequest |
HTTP request builder and executor.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
HttpRequest.Preset | Client's preset with timeout settings, listeners, etc. |
||||||||||
HttpRequest.RedirectHandler | Redirection handler interface. |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Constructor for | |||||||||||
Constructor for | |||||||||||
Constructor for |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Add a | |||||||||||
Add a cookie with given | |||||||||||
Add a cookie string. | |||||||||||
Add a header with given | |||||||||||
Removes all cookies added before. | |||||||||||
Removes all headers added before. | |||||||||||
Returns a deep copy of this builder. | |||||||||||
Executes HTTP request. | |||||||||||
Executes HTTP request and reads response. | |||||||||||
Sets the delay before opening previous and this connection. | |||||||||||
Sets HTTP request method to DELETE with request entity. | |||||||||||
Sets HTTP request method to GET. | |||||||||||
Sets HTTP request method to HEAD. | |||||||||||
Enabled or disables connection pooling. | |||||||||||
Sets the output stream as the destination of response. | |||||||||||
Sets HTTP request method to POST with request entity. | |||||||||||
Sets HTTP request method to PUT with request entity. | |||||||||||
Configures redirect handling with | |||||||||||
Configures response code handling. | |||||||||||
Sets the timeouts of connection. | |||||||||||
Sets the |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Constructor for HttpRequest
.
Parameters | |
---|---|
uri |
Uri :
URI for request. |
holder |
HttpHolder :
HttpHolder instance. May be null. |
preset |
HttpRequest.Preset :
Preset with configuration.
|
Constructor for HttpRequest
without preset.
Parameters | |
---|---|
uri |
Uri :
URI for request. |
holder |
HttpHolder :
HttpHolder instance. May be null.
|
Constructor for HttpRequest
. In most cases HttpRequest.Preset
can provide it's own
HttpHolder
, so you can use this constructor.
Parameters | |
---|---|
uri |
Uri :
URI for request. |
preset |
HttpRequest.Preset :
Preset with configuration.
|
Add a CookieBuilder
and concatenate it with existing one.
Parameters | |
---|---|
builder |
CookieBuilder :
CookieBuilder instance. |
Returns | |
---|---|
HttpRequest |
This builder. |
See also:
Add a cookie with given name
and value
.
Parameters | |
---|---|
name |
String :
Cookie name. |
value |
String :
Cookie value. |
Returns | |
---|---|
HttpRequest |
This builder. |
See also:
Add a cookie string.
Parameters | |
---|---|
cookie |
String :
Cookie string. |
Returns | |
---|---|
HttpRequest |
This builder. |
See also:
Add a header with given name
and value
.
Parameters | |
---|---|
name |
String :
Header name. |
value |
String :
Header value. |
Returns | |
---|---|
HttpRequest |
This builder. |
Removes all cookies added before.
Returns | |
---|---|
HttpRequest |
This builder. |
Removes all headers added before.
Returns | |
---|---|
HttpRequest |
This builder. |
Returns a deep copy of this builder. Request entities will be copied shallowly!
Returns | |
---|---|
HttpRequest |
Copy of builder. |
Executes HTTP request. This make available response headers with returned HttpHolder
.
Later you can read response body with read()
or disconnect.
Returns | |
---|---|
HttpHolder |
HTTP connection holder. |
Throws | |
---|---|
HttpException |
if HTTP exception occurred. |
Executes HTTP request and reads response.
Returns | |
---|---|
HttpResponse |
HTTP response. |
Throws | |
---|---|
HttpException |
if HTTP exception occurred. |
See also:
Sets the delay before opening previous and this connection. May be helpful in adjusting connection frequency.
Parameters | |
---|---|
delay |
int :
Delay in milliseconds. |
Returns | |
---|---|
HttpRequest |
This builder. |
Sets HTTP request method to DELETE with request entity.
Parameters | |
---|---|
entity |
RequestEntity :
RequestEntity instance. |
Returns | |
---|---|
HttpRequest |
This builder. |
Sets HTTP request method to GET.
Returns | |
---|---|
HttpRequest |
This builder. |
Sets HTTP request method to HEAD.
Returns | |
---|---|
HttpRequest |
This builder. |
Enabled or disables connection pooling. Enabled by default.
Parameters | |
---|---|
keepAlive |
boolean :
True to enable pooling, false to disable one. |
Returns | |
---|---|
HttpRequest |
This builder. |
Sets the output stream as the destination of response. In this case read()
method
will return null
value.
Parameters | |
---|---|
outputStream |
OutputStream :
Output stream. |
Returns | |
---|---|
HttpRequest |
This builder. |
Sets HTTP request method to POST with request entity.
Parameters | |
---|---|
entity |
RequestEntity :
RequestEntity instance. |
Returns | |
---|---|
HttpRequest |
This builder. |
Sets HTTP request method to PUT with request entity.
Parameters | |
---|---|
entity |
RequestEntity :
RequestEntity instance. |
Returns | |
---|---|
HttpRequest |
This builder. |
Configures redirect handling with HttpRequest.RedirectHandler
.
Parameters | |
---|---|
redirectHandler |
HttpRequest.RedirectHandler :
Redirect handler interface. |
Returns | |
---|---|
HttpRequest |
This builder. |
Configures response code handling. The checkResponseCode()
will be called automatically
if this handling enabled. Enabled by default.
Parameters | |
---|---|
successOnly |
boolean :
True to enable handling, false to disable one. |
Returns | |
---|---|
HttpRequest |
This builder. |
Sets the timeouts of connection.
Parameters | |
---|---|
connectTimeout |
int :
TCP handshake timeout in milliseconds. |
readTimeout |
int :
Max delay in milliseconds between reading data. |
Returns | |
---|---|
HttpRequest |
This builder. |
Sets the HttpValidator
to handle data changes with 304 Not Modified
.
Parameters | |
---|---|
validator |
HttpValidator :
HttpValidator instance. May be null. |
Returns | |
---|---|
HttpRequest |
This builder. |