| 限定符和类型 | 类和说明 |
|---|---|
protected static class |
HttpRequest.CloseOperation<V>
确保Closeable类关闭,使用适当的异常处理
|
protected static class |
HttpRequest.FlushOperation<V>
Class that and ensures a
Flushable gets flushed with proper
exception handling. |
protected static class |
HttpRequest.Operation<V>
操作执行一个回调处理完成后和处理嵌套的异常
|
| 构造器和说明 |
|---|
HttpRequest(String url,
String method)
Create HTTP connection wrapper
|
HttpRequest(URL url,
String method)
Create HTTP connection wrapper
|
| 限定符和类型 | 方法和说明 |
|---|---|
HttpRequest |
accept(String accept)
Set the 'Accept' header to given value
|
HttpRequest |
acceptCharset(String acceptCharset)
Set the 'Accept-Charset' header to given value
|
HttpRequest |
acceptEncoding(String acceptEncoding)
Set the 'Accept-Encoding' header to given value
|
HttpRequest |
acceptGzipEncoding()
Set the 'Accept-Encoding' header to 'gzip'
|
HttpRequest |
acceptJson()
Set the 'Accept' header to 'application/json'
|
static String |
append(String url,
Map<?,?> params)
Append given map as query parameters to the base URL
Each map entry's key will be a parameter name and the value's
Object.toString() will be the parameter value. |
static String |
append(String url,
Object... params)
Append given name/value pairs as query parameters to the base URL
The params argument is interpreted as a sequence of name/value pairs so
the given number of params must be divisible by 2.
|
HttpRequest |
authorization(String authorization)
Set the 'Authorization' header to given value
|
boolean |
badRequest()
Is the response code a 400 Bad Request?
|
HttpRequest |
basic(String name,
String password)
Set the 'Authorization' header to given values in Basic authentication
format
|
String |
body()
|
HttpRequest |
body(AtomicReference<String> output)
Get the response body as a
String and set it as the value of the
given reference. |
HttpRequest |
body(AtomicReference<String> output,
String charset)
Get the response body as a
String and set it as the value of the
given reference. |
String |
body(String charset)
Get response as
String in given character set
This will fall back to using the UTF-8 character set if the given charset
is null |
BufferedInputStream |
buffer()
Get response in a buffered stream
|
BufferedReader |
bufferedReader()
Get buffered reader to response body using the character set returned
from
charset() and the configured buffer size |
BufferedReader |
bufferedReader(String charset)
Get buffered reader to response body using the given character set r and
the configured buffer size
|
int |
bufferSize()
Get the configured buffer size
The default buffer size is 8,192 bytes
|
HttpRequest |
bufferSize(int size)
Set the size used when buffering and copying between streams
This size is also used for send and receive buffers created for both char
and byte arrays
The default buffer size is 8,192 bytes
|
byte[] |
bytes()
Get response as byte array
|
protected ByteArrayOutputStream |
byteStream()
Create byte array output stream
|
String |
cacheControl()
Get the 'Cache-Control' header from the response
|
String |
charset()
Get 'charset' parameter from 'Content-Type' response header
|
HttpRequest |
chunk(int size)
Set chunked streaming mode to the given size
|
protected HttpRequest |
closeOutput()
Close output stream
|
protected HttpRequest |
closeOutputQuietly()
|
int |
code()
Get the status code of the response
|
HttpRequest |
code(AtomicInteger output)
Set the value of the given
AtomicInteger to the status code of
the response |
HttpRequest |
connectTimeout(int timeout)
Set connect timeout on connection to given value
|
String |
contentEncoding()
Get the 'Content-Encoding' header from the response
|
int |
contentLength()
Get the 'Content-Length' header from the response
|
HttpRequest |
contentLength(int contentLength)
Set the 'Content-Length' request header to the given value
|
HttpRequest |
contentLength(String contentLength)
Set the 'Content-Length' request header to the given value
|
String |
contentType()
Get the 'Content-Type' header from the response
|
HttpRequest |
contentType(String contentType)
Set the 'Content-Type' request header to the given value
|
HttpRequest |
contentType(String contentType,
String charset)
Set the 'Content-Type' request header to the given value and charset
|
String |
cookie(String name)
Get response cookie
|
HttpRequest |
cookie(String name,
String value)
Set cookie. e.g: key1=val1; key2=val2;
|
Map<String,String> |
cookies()
Get response cookies
|
HttpRequest |
cookies(Map<String,String> cookies) |
protected HttpRequest |
copy(InputStream input,
OutputStream output)
Copy from input stream to output stream
|
protected HttpRequest |
copy(Reader input,
Writer output)
Copy from reader to writer
|
boolean |
created()
Is the response code a 201 Created?
|
long |
date()
Get the 'Date' header from the response
|
long |
dateHeader(String name)
Get a date header from the response falling back to returning -1 if the
header is missing or parsing fails
|
long |
dateHeader(String name,
long defaultValue)
Get a date header from the response falling back to returning the given
default value if the header is missing or parsing fails
|
static HttpRequest |
delete(String url)
Start a 'DELETE' request to the given URL
|
static HttpRequest |
delete(String baseUrl,
boolean encode,
Object... params)
Start a 'DELETE' request to the given URL along with the query params
|
static HttpRequest |
delete(String baseUrl,
Map<?,?> params,
boolean encode)
Start a 'DELETE' request to the given URL along with the query params
|
static HttpRequest |
delete(URL url)
Start a 'DELETE' request to the given URL
|
HttpRequest |
disconnect()
Disconnect the connection
|
static String |
encode(String url)
Encode the given URL as an ASCII
String
This method ensures the path and query segments of the URL are properly
encoded such as ' ' characters being encoded to '%20' or any UTF-8
characters that are non-ASCII. |
String |
eTag()
Get the 'ETag' header from the response
|
long |
expires()
Get the 'Expires' header from the response
|
HttpRequest |
followRedirects(boolean followRedirects)
Set whether or not the underlying connection should follow redirects in
the response.
|
HttpRequest |
form(Map.Entry<?,?> entry)
Write the key and value in the entry as form data to the request body
The pair specified will be URL-encoded in UTF-8 and sent with the
'application/x-www-form-urlencoded' content-type
|
HttpRequest |
form(Map.Entry<?,?> entry,
String charset)
Write the key and value in the entry as form data to the request body
The pair specified will be URL-encoded and sent with the
'application/x-www-form-urlencoded' content-type
|
HttpRequest |
form(Map<?,?> values)
Write the values in the map as form data to the request body
The pairs specified will be URL-encoded in UTF-8 and sent with the
'application/x-www-form-urlencoded' content-type
|
HttpRequest |
form(Map<?,?> values,
String charset)
Write the values in the map as encoded form data to the request body
|
HttpRequest |
form(Object name,
Object value)
Write the name/value pair as form data to the request body
The pair specified will be URL-encoded in UTF-8 and sent with the
'application/x-www-form-urlencoded' content-type
|
HttpRequest |
form(Object name,
Object value,
String charset)
Write the name/value pair as form data to the request body
The values specified will be URL-encoded and sent with the
'application/x-www-form-urlencoded' content-type
|
static HttpRequest |
get(String url)
Start a 'GET' request to the given URL
|
static HttpRequest |
get(String baseUrl,
boolean encode,
Object... params)
Start a 'GET' request to the given URL along with the query params
|
static HttpRequest |
get(String baseUrl,
Map<?,?> params,
boolean encode)
Start a 'GET' request to the given URL along with the query params
|
static HttpRequest |
get(URL url)
Start a 'GET' request to the given URL
|
HttpURLConnection |
getConnection()
Get underlying connection
|
protected String |
getParam(String value,
String paramName)
Get parameter value from header value
|
protected Map<String,String> |
getParams(String header)
Get parameter values from header value
|
static String |
getValidCharset(String charset) |
static HttpRequest |
head(String url)
Start a 'HEAD' request to the given URL
|
static HttpRequest |
head(String baseUrl,
boolean encode,
Object... params)
Start a 'GET' request to the given URL along with the query params
|
static HttpRequest |
head(String baseUrl,
Map<?,?> params,
boolean encode)
Start a 'HEAD' request to the given URL along with the query params
|
static HttpRequest |
head(URL url)
Start a 'HEAD' request to the given URL
|
HttpRequest |
header(Map.Entry<String,String> header)
Set header to have given entry's key as the name and value as the value
|
String |
header(String name)
Get a response header
|
HttpRequest |
header(String name,
Number value)
Set header name to given value
|
HttpRequest |
header(String name,
String value)
Set header name to given value
|
Map<String,List<String>> |
headers()
Get all the response headers
|
HttpRequest |
headers(Map<String,String> headers)
Set all headers found in given map where the keys are the header names
and the values are the header values
|
String[] |
headers(String name)
Get all values of the given header from the response
|
HttpRequest |
ifModifiedSince(long ifModifiedSince)
Set the 'If-Modified-Since' request header to the given value
|
HttpRequest |
ifNoneMatch(String ifNoneMatch)
Set the 'If-None-Match' request header to the given value
|
boolean |
ignoreCloseExceptions()
Get whether or not exceptions thrown by
Closeable.close() are
ignored |
HttpRequest |
ignoreCloseExceptions(boolean ignore)
Set whether or not to ignore exceptions that occur from calling
Closeable.close()
The default value of this setting is true |
int |
intHeader(String name)
Get an integer header from the response falling back to returning -1 if
the header is missing or parsing fails
|
int |
intHeader(String name,
int defaultValue)
Get an integer header value from the response falling back to the given
default value if the header is missing or if parsing fails
|
boolean |
isBodyEmpty()
Is the response body empty?
|
static void |
keepAlive(boolean keepAlive)
Set the 'http.keepAlive' property to the given value.
|
long |
lastModified()
Get the 'Last-Modified' header from the response
|
String |
location()
Get the 'Location' header from the response
|
static void |
maxConnections(int maxConnections)
Set the 'http.maxConnections' property to the given value.
|
String |
message()
Get status message of the response
|
String |
method()
Get the HTTP method of this request
|
boolean |
noContent()
Is the response code a 204 No Content?
|
static void |
nonProxyHosts(String... hosts)
Set the 'http.nonProxyHosts' property to the given host values.
|
boolean |
notFound()
Is the response code a 404 Not Found?
|
boolean |
notModified()
Is the response code a 304 Not Modified?
|
boolean |
ok()
Is the response code a 200 OK?
|
protected HttpRequest |
openOutput()
Open output stream
|
static HttpRequest |
options(String url)
Start an 'OPTIONS' request to the given URL
|
static HttpRequest |
options(URL url)
Start an 'OPTIONS' request to the given URL
|
String |
parameter(String headerName,
String paramName)
Get parameter with given name from header value in response
|
Map<String,String> |
parameters(String headerName)
Get all parameters from header value in response
This will be all key=value pairs after the first ';' that are separated
by a ';'
|
HttpRequest |
part(String name,
File part)
Write part of a multipart request to the request body
|
HttpRequest |
part(String name,
InputStream part)
Write part of a multipart request to the request body
|
HttpRequest |
part(String name,
Number part)
Write part of a multipart request to the request body
|
HttpRequest |
part(String name,
String part)
Write part of a multipart request to the request body
|
HttpRequest |
part(String name,
String filename,
File part)
Write part of a multipart request to the request body
|
HttpRequest |
part(String name,
String filename,
Number part)
Write part of a multipart request to the request body
|
HttpRequest |
part(String name,
String filename,
String part)
Write part of a multipart request to the request body
|
HttpRequest |
part(String name,
String filename,
String contentType,
File part)
Write part of a multipart request to the request body
|
HttpRequest |
part(String name,
String filename,
String contentType,
InputStream part)
Write part of a multipart request to the request body
|
HttpRequest |
part(String name,
String filename,
String contentType,
String part)
Write part of a multipart request to the request body
|
HttpRequest |
partHeader(String name,
String value)
Write a multipart header to the response body
|
static HttpRequest |
post(String url)
Start a 'POST' request to the given URL
|
static HttpRequest |
post(String baseUrl,
boolean encode,
Object... params)
Start a 'POST' request to the given URL along with the query params
|
static HttpRequest |
post(String baseUrl,
Map<?,?> params,
boolean encode)
Start a 'POST' request to the given URL along with the query params
|
static HttpRequest |
post(URL url)
Start a 'POST' request to the given URL
|
HttpRequest |
progress(UploadProgress callback)
Set the UploadProgress callback for this request
|
HttpRequest |
proxyAuthorization(String proxyAuthorization)
Set the 'Proxy-Authorization' header to given value
|
HttpRequest |
proxyBasic(String name,
String password)
Set the 'Proxy-Authorization' header to given values in Basic
authentication format
|
static void |
proxyHost(String host)
Set the 'http.proxyHost' and 'https.proxyHost' properties to the given
host value.
|
static void |
proxyPort(int port)
Set the 'http.proxyPort' and 'https.proxyPort' properties to the given
port number.
|
static HttpRequest |
put(String url)
Start a 'PUT' request to the given URL
|
static HttpRequest |
put(String baseUrl,
boolean encode,
Object... params)
Start a 'PUT' request to the given URL along with the query params
|
static HttpRequest |
put(String baseUrl,
Map<?,?> params,
boolean encode)
Start a 'PUT' request to the given URL along with the query params
|
static HttpRequest |
put(URL url)
Start a 'PUT' request to the given URL
|
InputStreamReader |
reader()
Get reader to response body using the character set returned from
charset() |
InputStreamReader |
reader(String charset)
Get reader to response body using given character set.
|
HttpRequest |
readTimeout(int timeout)
Set read timeout on connection to given value
|
HttpRequest |
receive(Appendable appendable)
Receive response into the given appendable
|
HttpRequest |
receive(File file)
Stream response body to file
|
HttpRequest |
receive(OutputStream output)
Stream response to given output stream
|
HttpRequest |
receive(PrintStream output)
Stream response to given print stream
|
HttpRequest |
receive(Writer writer)
Receive response into the given writer
|
HttpRequest |
referer(String referer)
Set the 'Referer' header to given value
|
HttpRequest |
send(byte[] input)
Write byte array to request body
|
HttpRequest |
send(File input)
Write contents of file to request body
|
HttpRequest |
send(InputStream input)
Write stream to request body
The given stream will be closed once sending completes
|
HttpRequest |
send(Reader input)
Write reader to request body
The given reader will be closed once sending completes
|
HttpRequest |
send(String value)
Write char sequence to request body
The charset configured via
contentType(String) will be used and
UTF-8 will be used if it is unset. |
String |
server()
Get the 'Server' header from the response
|
boolean |
serverError()
Is the response code a 500 Internal Server Error?
|
static void |
setConnectionFactory(ConnectionFactory connectionFactory)
设置一个ConnectionFactory,用于创建新的请求
|
protected HttpRequest |
startPart()
Start part of a multipart
|
InputStream |
stream()
Get stream to response body
|
String |
toString() |
static HttpRequest |
trace(String url)
Start a 'TRACE' request to the given URL
|
static HttpRequest |
trace(URL url)
Start a 'TRACE' request to the given URL
|
HttpRequest |
trustAllCerts()
Configure HTTPS connection to trust all certificates
This method does nothing if the current request is not a HTTPS request
|
HttpRequest |
trustAllHosts()
Configure HTTPS connection to trust all hosts using a custom
HostnameVerifier that always returns true for each
host verified
This method does nothing if the current request is not a HTTPS request |
HttpRequest |
uncompress(boolean uncompress)
Set whether or not the response body should be automatically uncompressed
when read from.
|
URL |
url()
Get the
URL of this request's connection |
HttpRequest |
useCaches(boolean useCaches)
Set value of
URLConnection.setUseCaches(boolean) |
HttpRequest |
useProxy(String proxyHost,
int proxyPort)
Configure an HTTP proxy on this connection.
|
HttpRequest |
userAgent(String userAgent)
Set the 'User-Agent' header to given value
|
protected HttpRequest |
writePartHeader(String name,
String filename)
Write part header
|
protected HttpRequest |
writePartHeader(String name,
String filename,
String contentType)
Write part header
|
OutputStreamWriter |
writer()
Create writer to request output stream
|
public HttpRequest(String url, String method) throws HttpRequestException
url - Remote resource URL.method - HTTP request method (e.g., "GET", "POST").HttpRequestExceptionpublic HttpRequest(URL url, String method) throws HttpRequestException
url - Remote resource URL.method - HTTP request method (e.g., "GET", "POST").HttpRequestExceptionpublic static void setConnectionFactory(ConnectionFactory connectionFactory)
public static String encode(String url) throws HttpRequestException
String
This method ensures the path and query segments of the URL are properly
encoded such as ' ' characters being encoded to '%20' or any UTF-8
characters that are non-ASCII. No encoding of URLs is done by default by
the HttpRequest constructors and so if URL encoding is needed
this method should be called before calling the HttpRequest
constructor.
url - HttpRequestExceptionpublic static String append(String url, Map<?,?> params)
Each map entry's key will be a parameter name and the value's
Object.toString() will be the parameter value.
url - params - public static String append(String url, Object... params)
The params argument is interpreted as a sequence of name/value pairs so the given number of params must be divisible by 2.
url - params - name/value pairspublic static HttpRequest get(String url) throws HttpRequestException
url - HttpRequestExceptionpublic static HttpRequest get(URL url) throws HttpRequestException
url - HttpRequestExceptionpublic static HttpRequest get(String baseUrl, Map<?,?> params, boolean encode)
baseUrl - params - The query parameters to include as part of the baseUrlencode - true to encode the full URL#append(CharSequence, Map),
#encode(CharSequence)public static HttpRequest get(String baseUrl, boolean encode, Object... params)
baseUrl - encode - true to encode the full URLparams - the name/value query parameter pairs to include as part of the
baseUrl#append(CharSequence, Object...),
#encode(CharSequence)public static HttpRequest post(String url) throws HttpRequestException
url - HttpRequestExceptionpublic static HttpRequest post(URL url) throws HttpRequestException
url - HttpRequestExceptionpublic static HttpRequest post(String baseUrl, Map<?,?> params, boolean encode)
baseUrl - params - the query parameters to include as part of the baseUrlencode - true to encode the full URLappend(String, Map),
encode(String)public static HttpRequest post(String baseUrl, boolean encode, Object... params)
baseUrl - encode - true to encode the full URLparams - the name/value query parameter pairs to include as part of the
baseUrlappend(String, Object...),
encode(String)public static HttpRequest put(String url) throws HttpRequestException
url - HttpRequestExceptionpublic static HttpRequest put(URL url) throws HttpRequestException
url - HttpRequestExceptionpublic static HttpRequest put(String baseUrl, Map<?,?> params, boolean encode)
baseUrl - params - the query parameters to include as part of the baseUrlencode - true to encode the full URLappend(String, Map),
encode(String)public static HttpRequest put(String baseUrl, boolean encode, Object... params)
baseUrl - encode - true to encode the full URLparams - the name/value query parameter pairs to include as part of the
baseUrlappend(String, Object...),
encode(String)public static HttpRequest delete(String url) throws HttpRequestException
url - HttpRequestExceptionpublic static HttpRequest delete(URL url) throws HttpRequestException
url - HttpRequestExceptionpublic static HttpRequest delete(String baseUrl, Map<?,?> params, boolean encode)
baseUrl - params - The query parameters to include as part of the baseUrlencode - true to encode the full URLappend(String, Map),
encode(String)public static HttpRequest delete(String baseUrl, boolean encode, Object... params)
baseUrl - encode - true to encode the full URLparams - the name/value query parameter pairs to include as part of the
baseUrlappend(String, Object...),
encode(String)public static HttpRequest head(String url) throws HttpRequestException
url - HttpRequestExceptionpublic static HttpRequest head(URL url) throws HttpRequestException
url - HttpRequestExceptionpublic static HttpRequest head(String baseUrl, Map<?,?> params, boolean encode)
baseUrl - params - The query parameters to include as part of the baseUrlencode - true to encode the full URLappend(String, Map),
encode(String)public static HttpRequest head(String baseUrl, boolean encode, Object... params)
baseUrl - encode - true to encode the full URLparams - the name/value query parameter pairs to include as part of the
baseUrlappend(String, Object...),
encode(String)public static HttpRequest options(String url) throws HttpRequestException
url - HttpRequestExceptionpublic static HttpRequest options(URL url) throws HttpRequestException
url - HttpRequestExceptionpublic static HttpRequest trace(String url) throws HttpRequestException
url - HttpRequestExceptionpublic static HttpRequest trace(URL url) throws HttpRequestException
url - HttpRequestExceptionpublic static void keepAlive(boolean keepAlive)
This setting will apply to all requests.
keepAlive - public static void maxConnections(int maxConnections)
This setting will apply to all requests.
maxConnections - public static void proxyHost(String host)
This setting will apply to all requests.
host - public static void proxyPort(int port)
This setting will apply to all requests.
port - public static void nonProxyHosts(String... hosts)
Hosts will be separated by a '|' character.
This setting will apply to all requests.
hosts - public HttpURLConnection getConnection()
public HttpRequest ignoreCloseExceptions(boolean ignore)
Closeable.close()
The default value of this setting is true
ignore - public boolean ignoreCloseExceptions()
Closeable.close() are
ignoredpublic int code()
throws HttpRequestException
HttpRequestExceptionpublic HttpRequest code(AtomicInteger output) throws HttpRequestException
AtomicInteger to the status code of
the responseoutput - HttpRequestExceptionpublic boolean ok()
throws HttpRequestException
HttpRequestExceptionpublic boolean created()
throws HttpRequestException
HttpRequestExceptionpublic boolean noContent()
throws HttpRequestException
HttpRequestExceptionpublic boolean serverError()
throws HttpRequestException
HttpRequestExceptionpublic boolean badRequest()
throws HttpRequestException
HttpRequestExceptionpublic boolean notFound()
throws HttpRequestException
HttpRequestExceptionpublic boolean notModified()
throws HttpRequestException
HttpRequestExceptionpublic String message() throws HttpRequestException
HttpRequestExceptionpublic HttpRequest disconnect()
public HttpRequest chunk(int size)
size - public HttpRequest bufferSize(int size)
This size is also used for send and receive buffers created for both char and byte arrays
The default buffer size is 8,192 bytes
size - public int bufferSize()
The default buffer size is 8,192 bytes
public HttpRequest uncompress(boolean uncompress)
This will only affect requests that have the 'Content-Encoding' response header set to 'gzip'.
This causes all receive methods to use a GZIPInputStream when
applicable so that higher level streams and readers can read the data
uncompressed.
Setting this option does not cause any request headers to be set
automatically so acceptGzipEncoding() should be used in
conjunction with this setting to tell the server to gzip the response.
uncompress - protected ByteArrayOutputStream byteStream()
public String body(String charset) throws HttpRequestException
String in given character set
This will fall back to using the UTF-8 character set if the given charset is null
charset - HttpRequestExceptionpublic String body() throws HttpRequestException
HttpRequestExceptionpublic HttpRequest body(AtomicReference<String> output) throws HttpRequestException
String and set it as the value of the
given reference.output - HttpRequestExceptionpublic HttpRequest body(AtomicReference<String> output, String charset) throws HttpRequestException
String and set it as the value of the
given reference.output - charset - HttpRequestExceptionpublic boolean isBodyEmpty()
throws HttpRequestException
HttpRequestExceptionpublic byte[] bytes()
throws HttpRequestException
HttpRequestExceptionpublic BufferedInputStream buffer() throws HttpRequestException
HttpRequestExceptionbufferSize(int)public InputStream stream() throws HttpRequestException
HttpRequestExceptionpublic InputStreamReader reader(String charset) throws HttpRequestException
This will fall back to using the UTF-8 character set if the given charset is null
charset - HttpRequestExceptionpublic InputStreamReader reader() throws HttpRequestException
charset()HttpRequestExceptionpublic BufferedReader bufferedReader(String charset) throws HttpRequestException
charset - HttpRequestExceptionbufferSize(int)public BufferedReader bufferedReader() throws HttpRequestException
charset() and the configured buffer sizeHttpRequestExceptionbufferSize(int)public HttpRequest receive(File file) throws HttpRequestException
file - HttpRequestExceptionpublic HttpRequest receive(OutputStream output) throws HttpRequestException
output - HttpRequestExceptionpublic HttpRequest receive(PrintStream output) throws HttpRequestException
output - HttpRequestExceptionpublic HttpRequest receive(Appendable appendable) throws HttpRequestException
appendable - HttpRequestExceptionpublic HttpRequest receive(Writer writer) throws HttpRequestException
writer - HttpRequestExceptionpublic HttpRequest readTimeout(int timeout)
timeout - public HttpRequest connectTimeout(int timeout)
timeout - public HttpRequest header(String name, String value)
name - value - public HttpRequest cookie(String name, String value)
key - val - public HttpRequest cookies(Map<String,String> cookies)
public HttpRequest header(String name, Number value)
name - value - public HttpRequest headers(Map<String,String> headers)
headers - public HttpRequest header(Map.Entry<String,String> header)
header - public String header(String name) throws HttpRequestException
name - HttpRequestExceptionpublic Map<String,List<String>> headers() throws HttpRequestException
HttpRequestExceptionpublic String cookie(String name)
name - cookie namepublic long dateHeader(String name) throws HttpRequestException
name - HttpRequestExceptionpublic long dateHeader(String name, long defaultValue) throws HttpRequestException
name - defaultValue - HttpRequestExceptionpublic int intHeader(String name) throws HttpRequestException
name - HttpRequestExceptionpublic int intHeader(String name, int defaultValue) throws HttpRequestException
name - defaultValue - HttpRequestExceptionpublic String[] headers(String name)
name - String header valuespublic String parameter(String headerName, String paramName)
headerName - paramName - public Map<String,String> parameters(String headerName)
This will be all key=value pairs after the first ';' that are separated by a ';'
headerName - protected Map<String,String> getParams(String header)
header - protected String getParam(String value, String paramName)
value - paramName - public String charset()
public HttpRequest userAgent(String userAgent)
userAgent - public HttpRequest referer(String referer)
referer - public HttpRequest useCaches(boolean useCaches)
URLConnection.setUseCaches(boolean)useCaches - public HttpRequest acceptEncoding(String acceptEncoding)
acceptEncoding - public HttpRequest acceptGzipEncoding()
uncompress(boolean)public HttpRequest acceptCharset(String acceptCharset)
acceptCharset - public String contentEncoding()
public String server()
public long date()
public String cacheControl()
public String eTag()
public long expires()
public long lastModified()
public String location()
public HttpRequest authorization(String authorization)
authorization - public HttpRequest proxyAuthorization(String proxyAuthorization)
proxyAuthorization - public HttpRequest basic(String name, String password)
name - password - public HttpRequest proxyBasic(String name, String password)
name - password - public HttpRequest ifModifiedSince(long ifModifiedSince)
ifModifiedSince - public HttpRequest ifNoneMatch(String ifNoneMatch)
ifNoneMatch - public HttpRequest contentType(String contentType)
contentType - public HttpRequest contentType(String contentType, String charset)
contentType - charset - public String contentType()
public int contentLength()
public HttpRequest contentLength(String contentLength)
contentLength - public HttpRequest contentLength(int contentLength)
contentLength - public HttpRequest accept(String accept)
accept - public HttpRequest acceptJson()
protected HttpRequest copy(InputStream input, OutputStream output) throws IOException
input - output - IOExceptionprotected HttpRequest copy(Reader input, Writer output) throws IOException
input - output - IOExceptionpublic HttpRequest progress(UploadProgress callback)
callback - protected HttpRequest closeOutput() throws IOException
HttpRequestExceptionIOExceptionprotected HttpRequest closeOutputQuietly() throws HttpRequestException
HttpRequestExceptionprotected HttpRequest openOutput() throws IOException
IOExceptionprotected HttpRequest startPart() throws IOException
IOExceptionprotected HttpRequest writePartHeader(String name, String filename) throws IOException
name - filename - IOExceptionprotected HttpRequest writePartHeader(String name, String filename, String contentType) throws IOException
name - filename - contentType - IOExceptionpublic HttpRequest part(String name, String part)
name - part - public HttpRequest part(String name, String filename, String part) throws HttpRequestException
name - filename - part - HttpRequestExceptionpublic HttpRequest part(String name, String filename, String contentType, String part) throws HttpRequestException
name - filename - contentType - value of the Content-Type part headerpart - HttpRequestExceptionpublic HttpRequest part(String name, Number part) throws HttpRequestException
name - part - HttpRequestExceptionpublic HttpRequest part(String name, String filename, Number part) throws HttpRequestException
name - filename - part - HttpRequestExceptionpublic HttpRequest part(String name, File part) throws HttpRequestException
name - part - HttpRequestExceptionpublic HttpRequest part(String name, String filename, File part) throws HttpRequestException
name - filename - part - HttpRequestExceptionpublic HttpRequest part(String name, String filename, String contentType, File part) throws HttpRequestException
name - filename - contentType - value of the Content-Type part headerpart - HttpRequestExceptionpublic HttpRequest part(String name, InputStream part) throws HttpRequestException
name - part - HttpRequestExceptionpublic HttpRequest part(String name, String filename, String contentType, InputStream part) throws HttpRequestException
name - filename - contentType - value of the Content-Type part headerpart - HttpRequestExceptionpublic HttpRequest partHeader(String name, String value) throws HttpRequestException
name - value - HttpRequestExceptionpublic HttpRequest send(File input) throws HttpRequestException
input - HttpRequestExceptionpublic HttpRequest send(byte[] input) throws HttpRequestException
input - HttpRequestExceptionpublic HttpRequest send(InputStream input) throws HttpRequestException
The given stream will be closed once sending completes
input - HttpRequestExceptionpublic HttpRequest send(Reader input) throws HttpRequestException
The given reader will be closed once sending completes
input - HttpRequestExceptionpublic HttpRequest send(String value) throws HttpRequestException
The charset configured via contentType(String) will be used and
UTF-8 will be used if it is unset.
value - HttpRequestExceptionpublic OutputStreamWriter writer() throws HttpRequestException
HttpRequestExceptionpublic HttpRequest form(Map<?,?> values) throws HttpRequestException
The pairs specified will be URL-encoded in UTF-8 and sent with the 'application/x-www-form-urlencoded' content-type
values - HttpRequestExceptionpublic HttpRequest form(Map.Entry<?,?> entry) throws HttpRequestException
The pair specified will be URL-encoded in UTF-8 and sent with the 'application/x-www-form-urlencoded' content-type
entry - HttpRequestExceptionpublic HttpRequest form(Map.Entry<?,?> entry, String charset) throws HttpRequestException
The pair specified will be URL-encoded and sent with the 'application/x-www-form-urlencoded' content-type
entry - charset - HttpRequestExceptionpublic HttpRequest form(Object name, Object value) throws HttpRequestException
The pair specified will be URL-encoded in UTF-8 and sent with the 'application/x-www-form-urlencoded' content-type
name - value - HttpRequestExceptionpublic HttpRequest form(Object name, Object value, String charset) throws HttpRequestException
The values specified will be URL-encoded and sent with the 'application/x-www-form-urlencoded' content-type
name - value - charset - HttpRequestExceptionpublic HttpRequest form(Map<?,?> values, String charset) throws HttpRequestException
values - charset - HttpRequestExceptionpublic HttpRequest trustAllCerts() throws HttpRequestException
This method does nothing if the current request is not a HTTPS request
HttpRequestExceptionpublic HttpRequest trustAllHosts()
HostnameVerifier that always returns true for each
host verified
This method does nothing if the current request is not a HTTPS request
public String method()
public HttpRequest useProxy(String proxyHost, int proxyPort)
proxyBasic(String, String) if this proxy requires basic
authentication.proxyHost - proxyPort - public HttpRequest followRedirects(boolean followRedirects)
followRedirects - - true fo follow redirects, false to not.Copyright © 2016. All rights reserved.