public class HttpRequest extends Object
Modifier and Type | Field and Description |
---|---|
protected HttpConnection |
connection
The underlying HTTPS connection stream.
|
Modifier | Constructor and Description |
---|---|
protected |
HttpRequest() |
|
HttpRequest(URL url,
HttpMethod method,
byte[] body)
Constructor.
|
|
HttpRequest(URL url,
HttpMethod method,
byte[] body,
Proxy proxy)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
HttpResponse |
send()
Executes the HTTPS request.
|
HttpRequest |
setConnectTimeoutMillis(int timeout)
Set the connect timeout, in milliseconds, for the request.
|
HttpRequest |
setHeaderField(String field,
String value)
Sets the header field to the given value.
|
HttpRequest |
setReadTimeoutMillis(int timeout)
Sets the read timeout, in milliseconds, for the request.
|
protected final HttpConnection connection
public HttpRequest(URL url, HttpMethod method, byte[] body) throws IOException
url
- The URL for the request.method
- The HTTPS request method (i.e. GET).body
- The request body. Must be an array of size 0 if the request method is GET or DELETE.IOException
- This exception thrown if an IOException occurs
in setting up the HTTPS connection.IllegalArgumentException
- This exception thrown if the endpoint
given does not use the HTTPS protocol.public HttpRequest(URL url, HttpMethod method, byte[] body, Proxy proxy) throws IOException
url
- The URL for the request.method
- The HTTPS request method (i.e. GET).body
- The request body. Must be an array of size 0 if the request method is GET or DELETE.proxy
- The proxy to send the request through. May be null if no proxy should be usedIOException
- This exception thrown if an IOException occurs
in setting up the HTTPS connection.IllegalArgumentException
- This exception thrown if the endpoint
given does not use the HTTPS protocol.protected HttpRequest()
public HttpResponse send() throws IOException
IOException
- This exception thrown if the connection could not be
established, or the input/output streams could not be accessed.public HttpRequest setHeaderField(String field, String value)
field
- The header field name.value
- The header field value.public HttpRequest setReadTimeoutMillis(int timeout)
timeout
- The read timeout.public HttpRequest setConnectTimeoutMillis(int timeout)
timeout
- the connect timeoutCopyright © 2020. All rights reserved.