public abstract class AbstractHttpRequest extends Object
Modifier and Type | Field and Description |
---|---|
protected Authentication |
auth |
static String |
DEFAULT_ENCODING |
protected Integer |
lastHttpStatusCode |
protected InputStream |
lastResponseStream |
protected String |
url |
static String |
USER_AGENT |
Constructor and Description |
---|
AbstractHttpRequest() |
Modifier and Type | Method and Description |
---|---|
void |
execute()
Executes this HTTP request and preserves the response stream and HTTP
response code for processing.
|
protected abstract HttpURLConnection |
getConnection()
The method class will create the appropriate connection with an endpoint,
parameters, etc.
|
protected static HttpURLConnection |
getProxiedConnection(String url)
Creates an HTTP connection.
|
long |
getResponseAsFile(File f)
Write the last response to a file.
|
String |
getResponseBody()
Returns the last response stream as a string.
|
Integer |
getResponseCode()
Returns the last HTTP response code.
|
public static final String DEFAULT_ENCODING
public static final String USER_AGENT
protected String url
protected Authentication auth
protected Integer lastHttpStatusCode
protected InputStream lastResponseStream
public void execute() throws HelloSignException
HelloSignException
- Thrown if there is an error while making the
HTTP request to the HelloSign API.public Integer getResponseCode()
public String getResponseBody()
protected static HttpURLConnection getProxiedConnection(String url) throws MalformedURLException, IOException
url
- String URL to connect toMalformedURLException
- thrown if the URL is invalidIOException
- thrown if IO cannot be established with the URLprotected abstract HttpURLConnection getConnection() throws HelloSignException
HelloSignException
- Thrown if a connection cannot be createdpublic long getResponseAsFile(File f) throws HelloSignException
f
- FileHelloSignException
- Thrown if an exception occurs during the copy
of the response stream to the given file.Copyright © 2017 HelloSign. All rights reserved.