public class URLStreamProvider extends Object implements StreamProvider
Modifier and Type | Class and Description |
---|---|
static class |
URLStreamProvider.AmbariHttpUrlConnectionProvider
A default implementation of
HttpURLConnectionProvider , this class
will use the URLStreamProvider in order to provide an
HttpURLConnection which is able to use Ambari's cookie store,
truststore, and timeout values. |
Constructor and Description |
---|
URLStreamProvider(int connectionTimeout,
int readTimeout,
ComponentSSLConfiguration configuration)
Provide the connection timeout for the underlying connection.
|
URLStreamProvider(int connectionTimeout,
int readTimeout,
String trustStorePath,
String trustStorePassword,
String trustStoreType)
Provide the connection timeout for the underlying connection.
|
Modifier and Type | Method and Description |
---|---|
static String |
appendCookie(String cookies,
String newCookie)
Utility method to append a new cookie value to an existing list of cookies.
|
AppCookieManager |
getAppCookieManager()
Get the associated app cookie manager.
|
protected HttpURLConnection |
getConnection(String spec) |
boolean |
getSetupTruststoreForHttps() |
protected HttpsURLConnection |
getSSLConnection(String spec) |
HttpURLConnection |
processURL(String spec,
String requestMethod,
byte[] body,
Map<String,List<String>> headers)
Get a URL connection from the given spec.
|
HttpURLConnection |
processURL(String spec,
String requestMethod,
InputStream body,
Map<String,List<String>> headers)
Get a URL connection from the given spec.
|
HttpURLConnection |
processURL(String spec,
String requestMethod,
String body,
Map<String,List<String>> headers)
Get a URL connection from the given spec.
|
InputStream |
readFrom(String spec) |
InputStream |
readFrom(String spec,
String requestMethod,
String params) |
void |
setSetupTruststoreForHttps(boolean setupTruststoreForHttps) |
public static final String COOKIE
public URLStreamProvider(int connectionTimeout, int readTimeout, ComponentSSLConfiguration configuration)
connectionTimeout
- time, in milliseconds, to attempt a connectionreadTimeout
- the read timeout in millisecondsconfiguration
- configuration holding TrustStore informationpublic URLStreamProvider(int connectionTimeout, int readTimeout, String trustStorePath, String trustStorePassword, String trustStoreType)
connectionTimeout
- time, in milliseconds, to attempt a connectionreadTimeout
- the read timeout in millisecondstrustStorePath
- the path to the truststore required for secure connectionstrustStorePassword
- the truststore passwordtrustStoreType
- the truststore type (e.g. "JKS")public void setSetupTruststoreForHttps(boolean setupTruststoreForHttps)
public boolean getSetupTruststoreForHttps()
public InputStream readFrom(String spec, String requestMethod, String params) throws IOException
readFrom
in interface StreamProvider
IOException
public InputStream readFrom(String spec) throws IOException
readFrom
in interface StreamProvider
IOException
public HttpURLConnection processURL(String spec, String requestMethod, String body, Map<String,List<String>> headers) throws IOException
spec
- the String to parse as a URLrequestMethod
- the HTTP method (GET,POST,PUT,etc.).body
- the body of the request; may be nullheaders
- the headers of the request; may be nullIOException
- if the URL connection can not be establishedpublic HttpURLConnection processURL(String spec, String requestMethod, InputStream body, Map<String,List<String>> headers) throws IOException
spec
- the String to parse as a URLrequestMethod
- the HTTP method (GET,POST,PUT,etc.).body
- the body of the request; may be nullheaders
- the headers of the request; may be nullIOException
- if the URL connection can not be establishedpublic HttpURLConnection processURL(String spec, String requestMethod, byte[] body, Map<String,List<String>> headers) throws IOException
spec
- the String to parse as a URLrequestMethod
- the HTTP method (GET,POST,PUT,etc.).body
- the body of the request; may be nullheaders
- the headers of the request; may be nullIOException
- if the URL connection can not be establishedpublic AppCookieManager getAppCookieManager()
public static String appendCookie(String cookies, String newCookie)
cookies
- the semicolon separated list of cookie valuesnewCookie
- a new cookie value to be appended.protected HttpURLConnection getConnection(String spec) throws IOException
IOException
protected HttpsURLConnection getSSLConnection(String spec) throws IOException, IllegalStateException
IOException
IllegalStateException
Copyright © 2022 Apache Software Foundation. All rights reserved.