HttpRequest Class

  • java.lang.Object
    • com.microsoft.azure.sdk.iot.provisioning.device.transport.https.HttpRequest

public class HttpRequest

Constructor Summary

Constructor Description
HttpRequest()
HttpRequest(URL url, HttpMethod method, byte[] body)

Constructor. Takes a URL as an argument and returns an HTTPS request that is ready to be sent.

Method Summary

Modifier and Type Method and Description
HttpResponse send()

Executes the HTTPS 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. The read timeout is the number of milliseconds after the server receives a request and before the server sends data back.

HttpRequest setSSLContext(SSLContext sslContext)

Constructor Details

HttpRequest

protected HttpRequest()

HttpRequest

public HttpRequest(URL url, HttpMethod method, byte[] body)

Constructor. Takes a URL as an argument and returns an HTTPS request that is ready to be sent.

Parameters:

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.

Throws:

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.

Method Details

send

public HttpResponse send()

Executes the HTTPS request.

Returns:

The HTTPS response.

Throws:

IOException - This exception thrown if the connection could not be established, or the input/output streams could not be accessed.

setHeaderField

public HttpRequest setHeaderField(String field, String value)

Sets the header field to the given value.

Parameters:

field - The header field name.
value - The header field value.

Returns:

The object itself, for fluent setting.

setReadTimeoutMillis

public HttpRequest setReadTimeoutMillis(int timeout)

Sets the read timeout, in milliseconds, for the request. The read timeout is the number of milliseconds after the server receives a request and before the server sends data back.

Parameters:

timeout - The read timeout.

Returns:

The object itself, for fluent setting.

setSSLContext

public HttpRequest setSSLContext(SSLContext sslContext)

Parameters:

sslContext

Applies to