Class Get
- All Implemented Interfaces:
SimpleGet
HttpsJwks) that
uses URL and HttpsURLConnection to make
basic HTTP GET requests.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionMake an HTTP GET requestvoidsetConnectTimeout(int connectTimeout) Sets a specified timeout value, in milliseconds, to be used by the underlying URLConnection when opening a communications link to the resource referenced by the URLConnection.voidsetHostnameVerifier(HostnameVerifier hostnameVerifier) Sets the HostnameVerifier used by the underlying HttpsURLConnection.voidsetHttpProxy(Proxy proxy) Sets the Proxy through which the connection will be made withURL.openConnection(Proxy).voidsetInitialRetryWaitTime(long initialRetryWaitTime) Sets the initial wait time for retry requests.voidsetProgressiveRetryWait(boolean progressiveRetryWait) Sets whether a progressively longer wait time should be used between retry attempts (up to a max of 8000).voidsetReadTimeout(int readTimeout) Sets the read timeout to the specified value, in milliseconds, for the underlying URLConnection.voidsetResponseBodySizeLimit(int responseBodySizeLimit) Sets a limit on the size of the response body that will be consumed.voidsetRetries(int retries) Sets the number times to retry in the case of a request that failed for a reason that potently could be recovered from.voidsetSslSocketFactory(SSLSocketFactory sslSocketFactory) Sets the SSLSocketFactory to used when creating sockets for HTTPS connections, which allows for control over the details of creating and initially configuring the secure sockets such as setting authentication keys, peer certificate validation, enabled cipher suites, and so on.voidsetTrustedCertificates(X509Certificate... certificates) voidsetTrustedCertificates(Collection<X509Certificate> certificates) Sets the certificates that will be used by the underlying HttpsURLConnection as trust anchors when validating the HTTPS certificate presented by the server.
-
Constructor Details
-
Get
public Get()
-
-
Method Details
-
get
Description copied from interface:SimpleGetMake an HTTP GET request- Specified by:
getin interfaceSimpleGet- Parameters:
location- the HTTP(S) URL- Returns:
- a SimpleResponse object representing the result of the HTTP GET request
- Throws:
IOException- if a problem occurs with the request
-
setConnectTimeout
public void setConnectTimeout(int connectTimeout) Sets a specified timeout value, in milliseconds, to be used by the underlying URLConnection when opening a communications link to the resource referenced by the URLConnection. Default is 20000.- Parameters:
connectTimeout- the timeout value to be used in milliseconds
-
setReadTimeout
public void setReadTimeout(int readTimeout) Sets the read timeout to the specified value, in milliseconds, for the underlying URLConnection. Default is 20000.- Parameters:
readTimeout- the timeout value to be used in milliseconds
-
setHostnameVerifier
Sets the HostnameVerifier used by the underlying HttpsURLConnection.- Parameters:
hostnameVerifier- the host name verifier
-
setTrustedCertificates
- Parameters:
certificates- certificates to trust
-
setRetries
public void setRetries(int retries) Sets the number times to retry in the case of a request that failed for a reason that potently could be recovered from. Default is 3.- Parameters:
retries- the number of times to retry
-
setProgressiveRetryWait
public void setProgressiveRetryWait(boolean progressiveRetryWait) Sets whether a progressively longer wait time should be used between retry attempts (up to a max of 8000). Defaut is true.- Parameters:
progressiveRetryWait- true for a progressively longer retry wait time, false for a static retry wait time
-
setInitialRetryWaitTime
public void setInitialRetryWaitTime(long initialRetryWaitTime) Sets the initial wait time for retry requests. Default is 180.- Parameters:
initialRetryWaitTime- wait time in milliseconds
-
setResponseBodySizeLimit
public void setResponseBodySizeLimit(int responseBodySizeLimit) Sets a limit on the size of the response body that will be consumed. Default is 1,024,512.- Parameters:
responseBodySizeLimit- size limit of the response body in number of characters, -1 indicates no limit
-
setTrustedCertificates
Sets the certificates that will be used by the underlying HttpsURLConnection as trust anchors when validating the HTTPS certificate presented by the server. When this method is used, the provided certificates become the only trusted certificates for the instance (the ones from the java runtime won't be used in that context anymore).Note that only one of
setSslSocketFactory(SSLSocketFactory)orsetTrustedCertificates(Collection)orsetTrustedCertificates(X509Certificate...)should be used per instance of this class as each results in the setting of the underlying SSLSocketFactory used by the HttpsURLConnection and the last method to be called will effectively override the others.- Parameters:
certificates- certificates to trust
-
setSslSocketFactory
Sets the SSLSocketFactory to used when creating sockets for HTTPS connections, which allows for control over the details of creating and initially configuring the secure sockets such as setting authentication keys, peer certificate validation, enabled cipher suites, and so on.
Note that only one of
setSslSocketFactory(SSLSocketFactory)orsetTrustedCertificates(Collection)orsetTrustedCertificates(X509Certificate...)should be used per instance of this class as each results in the setting of the underlying SSLSocketFactory used by the HttpsURLConnection and the last method to be called will effectively override the others.- Parameters:
sslSocketFactory- the SSLSocketFactory
-
setHttpProxy
Sets the Proxy through which the connection will be made withURL.openConnection(Proxy). By default no Proxy is used when making the connection - e.g. justURL.openConnection().- Parameters:
proxy- the Proxy through which the connection will be made
-