HttpsRequest Class

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

public class HttpsRequest

An HTTPS request.

Constructor Summary

Constructor Description
HttpsRequest()
HttpsRequest(URL url, HttpsMethod method, byte[] body, String userAgentString)

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

HttpsRequest(URL url, HttpsMethod method, byte[] body, String userAgentString, ProxySettings proxySettings)

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
byte [] getBody()
String getHttpMethod()
String getRequestHeaders()
URL getRequestUrl()
HttpsResponse send()

Executes the HTTPS request.

HttpsResponse sendAsHttpRequest()

Executes the HTTPS request as an HTTP request. This method should only be called when a user supplied url contains HTTP rather than HTTPS. Currently, this only happens from the HttpsHsmClient for some edge workload urls.

HttpsRequest setConnectTimeout(int timeout)

Sets the connect timeout, in milliseconds, for the request.

HttpsRequest setHeaderField(String field, String value)

Sets the header field to the given value.

HttpsRequest setReadTimeout(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.

HttpsRequest setSSLContext(SSLContext sslContext)

Sets this object's SSL context

Constructor Details

HttpsRequest

protected HttpsRequest()

HttpsRequest

public HttpsRequest(URL url, HttpsMethod method, byte[] body, String userAgentString)

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.
userAgentString - the user agent string to attach to all http communications

HttpsRequest

public HttpsRequest(URL url, HttpsMethod method, byte[] body, String userAgentString, ProxySettings proxySettings)

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.
userAgentString - the user agent string to attach to all http communications
proxySettings - The proxy settings to use when connecting. If null then no proxy will be used

Method Details

getBody

public byte [] getBody()

getHttpMethod

public String getHttpMethod()

getRequestHeaders

public String getRequestHeaders()

getRequestUrl

public URL getRequestUrl()

send

public HttpsResponse send()

Executes the HTTPS request.

Returns:

an HTTPS response.

Throws:

TransportException - if the connection could not be established, or the input/output streams could not be accessed.

sendAsHttpRequest

public HttpsResponse sendAsHttpRequest()

Executes the HTTPS request as an HTTP request. This method should only be called when a user supplied url contains HTTP rather than HTTPS. Currently, this only happens from the HttpsHsmClient for some edge workload urls.

Returns:

an HTTPS response.

Throws:

TransportException - if the connection could not be established, or the input/output streams could not be accessed.

setConnectTimeout

public HttpsRequest setConnectTimeout(int timeout)

Sets the connect timeout, in milliseconds, for the request.

Parameters:

timeout - the connect timeout in milliseconds.

Returns:

itself, for fluent setting.

setHeaderField

public HttpsRequest 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:

itself, for fluent setting.

setReadTimeout

public HttpsRequest setReadTimeout(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:

itself, for fluent setting.

setSSLContext

public HttpsRequest setSSLContext(SSLContext sslContext)

Sets this object's SSL context

Parameters:

sslContext - the value to set this object's SSL context too

Returns:

itself, for fluent setting.

Throws:

IllegalArgumentException - if sslContext is null

Applies to