Package com.hellosign.sdk.http
Class AbstractHttpRequest
- java.lang.Object
-
- com.hellosign.sdk.http.AbstractHttpRequest
-
- Direct Known Subclasses:
HttpDeleteRequest
,HttpGetRequest
,HttpOptionsRequest
,HttpPostRequest
public abstract class AbstractHttpRequest extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description protected Authentication
auth
static java.lang.String
DEFAULT_ENCODING
protected java.lang.Integer
lastHttpStatusCode
protected java.io.InputStream
lastResponseStream
protected java.lang.String
url
static java.lang.String
USER_AGENT
-
Constructor Summary
Constructors Constructor Description AbstractHttpRequest()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
execute()
Executes this HTTP request and preserves the response stream and HTTP response code for processing.protected abstract java.net.HttpURLConnection
getConnection()
The method class will create the appropriate connection with an endpoint, parameters, etc.protected static java.net.HttpURLConnection
getProxiedConnection(java.lang.String url)
Creates an HTTP connection.long
getResponseAsFile(java.io.File f)
Write the last response to a file.java.lang.String
getResponseBody()
Returns the last response stream as a string.java.lang.Integer
getResponseCode()
Returns the last HTTP response code.
-
-
-
Field Detail
-
DEFAULT_ENCODING
public static final java.lang.String DEFAULT_ENCODING
- See Also:
- Constant Field Values
-
USER_AGENT
public static final java.lang.String USER_AGENT
-
url
protected java.lang.String url
-
auth
protected Authentication auth
-
lastHttpStatusCode
protected java.lang.Integer lastHttpStatusCode
-
lastResponseStream
protected java.io.InputStream lastResponseStream
-
-
Method Detail
-
getProxiedConnection
protected static java.net.HttpURLConnection getProxiedConnection(java.lang.String url) throws java.net.MalformedURLException, java.io.IOException
Creates an HTTP connection. Optionally checks for proxy parameters and creates a proxied connection using the system properties: "hellosign.proxy.url" - the URL of the HTTP proxy "hellosign.proxy.port" - the port of the HTTP proxy- Parameters:
url
- String URL to connect to- Returns:
- HttpUrlConnection the (proxied) connection to the URL
- Throws:
java.net.MalformedURLException
- thrown if the URL is invalidjava.io.IOException
- thrown if IO cannot be established with the URL
-
execute
public void execute() throws HelloSignException
Executes this HTTP request and preserves the response stream and HTTP response code for processing.- Throws:
HelloSignException
- Thrown if there is an error while making the HTTP request to the HelloSign API.
-
getResponseCode
public java.lang.Integer getResponseCode()
Returns the last HTTP response code.- Returns:
- Integer response code
-
getResponseBody
public java.lang.String getResponseBody()
Returns the last response stream as a string.- Returns:
- String
-
getConnection
protected abstract java.net.HttpURLConnection getConnection() throws HelloSignException
The method class will create the appropriate connection with an endpoint, parameters, etc.- Returns:
- HttpURLConnection
- Throws:
HelloSignException
- Thrown if a connection cannot be created
-
getResponseAsFile
public long getResponseAsFile(java.io.File f) throws HelloSignException
Write the last response to a file.- Parameters:
f
- File- Returns:
- long bytes written
- Throws:
HelloSignException
- Thrown if an exception occurs during the copy of the response stream to the given file.
-
-