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 Authenticationauthstatic java.lang.StringDEFAULT_ENCODINGprotected java.lang.IntegerlastHttpStatusCodeprotected java.io.InputStreamlastResponseStreamprotected java.lang.Stringurlstatic java.lang.StringUSER_AGENT
-
Constructor Summary
Constructors Constructor Description AbstractHttpRequest()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidexecute()Executes this HTTP request and preserves the response stream and HTTP response code for processing.protected abstract java.net.HttpURLConnectiongetConnection()The method class will create the appropriate connection with an endpoint, parameters, etc.protected static java.net.HttpURLConnectiongetProxiedConnection(java.lang.String url)Creates an HTTP connection.longgetResponseAsFile(java.io.File f)Write the last response to a file.java.lang.StringgetResponseBody()Returns the last response stream as a string.java.lang.IntegergetResponseCode()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.IOExceptionCreates 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 HelloSignExceptionExecutes 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 HelloSignExceptionThe 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 HelloSignExceptionWrite 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.
-
-