public class HttpClient extends Object
Constructor and Description |
---|
HttpClient() |
Modifier and Type | Method and Description |
---|---|
File |
asFile(String fileName)
Executes the request and returns the response as a File.
|
int |
asHttpCode()
Executes the request and returns the HTTP response code.
|
org.json.JSONObject |
asJson()
Executes the request and returns the response as a JSONObject.
|
HttpClient |
delete(String url)
Initializes a DELETE request to the given URL.
|
HttpClient |
get(String url)
Initializes a GET request to the given URL.
|
String |
getLastResponse()
Returns the response to the last HTTP request as a string.
|
long |
getLastResponseAsFile(File f)
Returns the last HTTP request body as a file.
|
Integer |
getLastResponseCode()
Returns the HTTP status code for the last request.
|
HttpClient |
options(String url)
Makes an OPTIONS request to the given URL
|
HttpClient |
post(String url)
Initializes a POST request to the given URL.
|
HttpClient |
put(String url)
Makes a PUT request to the given URL
|
HttpClient |
withAuth(Authentication auth) |
HttpClient |
withGetParam(String key,
String value) |
HttpClient |
withGetParams(Map<String,String> params) |
HttpClient |
withPostField(String key,
Serializable value) |
HttpClient |
withPostFields(Map<String,Serializable> fields) |
public HttpClient withAuth(Authentication auth)
public HttpClient withGetParam(String key, String value)
public HttpClient withGetParams(Map<String,String> params)
public HttpClient withPostField(String key, Serializable value)
public HttpClient withPostFields(Map<String,Serializable> fields)
public String getLastResponse()
public Integer getLastResponseCode()
public long getLastResponseAsFile(File f) throws HelloSignException
f
- File that should contain the responseHelloSignException
- thrown if there is a problem writing to the
file or reading the response streampublic org.json.JSONObject asJson() throws HelloSignException
HelloSignException
- thrown if there is a problem executing the
requestpublic File asFile(String fileName) throws HelloSignException
fileName
- String name of destination fileHelloSignException
- thrown if there is a problem executing the
requestpublic int asHttpCode() throws HelloSignException
HelloSignException
- thrown if no request has been performedpublic HttpClient get(String url) throws HelloSignException
url
- String urlHelloSignException
- thrown if the url is invalidpublic HttpClient post(String url) throws HelloSignException
url
- String urlHelloSignException
- thrown if the url is invalidpublic HttpClient delete(String url) throws HelloSignException
url
- String urlHelloSignException
- thrown if the url is invalidpublic HttpClient put(String url) throws HelloSignException
url
- String urlHelloSignException
- thrown if the url is invalidpublic HttpClient options(String url) throws HelloSignException
url
- String URLHelloSignException
- thrown if the URL is invalidCopyright © 2017 HelloSign. All rights reserved.