public class HttpRequest extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
IF_MATCH |
static String |
REQUEST_ID |
| Modifier | Constructor and Description |
|---|---|
protected |
HttpRequest() |
|
HttpRequest(URL url,
HttpMethod method,
byte[] body,
String authorizationToken)
Constructor.
|
|
HttpRequest(URL url,
HttpMethod method,
byte[] body,
String authorizationToken,
Proxy proxy)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
HttpResponse |
send()
Executes the HTTPS request.
|
HttpRequest |
setConnectTimeoutSeconds(int timeout)
Set the connect timeout, in seconds, for the request.
|
HttpRequest |
setHeaderField(String field,
String value)
Sets the header field to the given value.
|
HttpRequest |
setHeaders(Map<String,String> headers)
Sets the header field to the given value.
|
HttpRequest |
setReadTimeoutSeconds(int timeout)
Sets the read timeout, in seconds, for the request.
|
public static final String REQUEST_ID
public static final String IF_MATCH
public HttpRequest(URL url, HttpMethod method, byte[] body, String authorizationToken) 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.authorizationToken - The header value for the Authorization header.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, String authorizationToken, 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.authorizationToken - The header value for the Authorization header.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 IotHubException, IOException
IOException - This exception thrown if the connection could not be
established, or the input/output streams could not be accessed.IotHubException - if the http request was successful, but IoT hub responded with an error codepublic HttpRequest setHeaderField(String field, String value)
field - The header field name.value - The header field value.public HttpRequest setHeaders(Map<String,String> headers)
headers - The set of headers to use for this requestpublic HttpRequest setReadTimeoutSeconds(int timeout)
timeout - The read timeout.public HttpRequest setConnectTimeoutSeconds(int timeout)
timeout - the connect timeoutCopyright © 2024. All rights reserved.