| 程序包 | 说明 |
|---|---|
| cn.ponfee.commons.http |
| 限定符和类型 | 方法和说明 |
|---|---|
boolean |
HttpRequest.badRequest()
Is the response code a 400 Bad Request?
|
String |
HttpRequest.body()
Get response as
String using character set returned from
HttpRequest.charset() |
HttpRequest |
HttpRequest.body(AtomicReference<String> output)
Get the response body as a
String and set it as the value of the
given reference. |
HttpRequest |
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 |
HttpRequest.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 |
HttpRequest.buffer()
Get response in a buffered stream
|
BufferedReader |
HttpRequest.bufferedReader()
Get buffered reader to response body using the character set returned from
HttpRequest.charset() and the configured buffer size |
BufferedReader |
HttpRequest.bufferedReader(String charset)
Get buffered reader to response body using the given character set r and
the configured buffer size
|
protected HttpRequest |
HttpRequest.closeOutputQuietly()
|
int |
HttpRequest.code()
Get the status code of the response
|
HttpRequest |
HttpRequest.code(AtomicInteger output)
Set the value of the given
AtomicInteger to the status code of the
response |
boolean |
HttpRequest.created()
Is the response code a 201 Created?
|
long |
HttpRequest.dateHeader(String name)
Get a date header from the response falling back to returning -1 if the
header is missing or parsing fails
|
long |
HttpRequest.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 |
HttpRequest.delete(CharSequence url)
Start a 'DELETE' request to the given URL
|
static HttpRequest |
HttpRequest.delete(URL url)
Start a 'DELETE' request to the given URL
|
static String |
HttpRequest.encode(CharSequence 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. |
HttpRequest |
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 |
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 |
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 |
HttpRequest.form(Map<?,?> values,
String charset)
Write the values in the map as encoded form data to the request body
|
HttpRequest |
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 |
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 |
HttpRequest.get(CharSequence url)
Start a 'GET' request to the given URL
|
static HttpRequest |
HttpRequest.get(URL url)
Start a 'GET' request to the given URL
|
static HttpRequest |
HttpRequest.head(CharSequence url)
Start a 'HEAD' request to the given URL
|
static HttpRequest |
HttpRequest.head(URL url)
Start a 'HEAD' request to the given URL
|
String |
HttpRequest.header(String name)
Get a response header
|
Map<String,List<String>> |
HttpRequest.headers()
Get all the response headers
|
int |
HttpRequest.intHeader(String name)
Get an integer header from the response falling back to returning -1 if the
header is missing or parsing fails
|
int |
HttpRequest.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 |
HttpRequest.isBodyEmpty()
Is the response body empty?
|
String |
HttpRequest.message()
Get status message of the response
|
boolean |
HttpRequest.noContent()
Is the response code a 204 No Content?
|
boolean |
HttpRequest.notFound()
Is the response code a 404 Not Found?
|
boolean |
HttpRequest.notModified()
Is the response code a 304 Not Modified?
|
boolean |
HttpRequest.ok()
Is the response code a 200 OK?
|
static HttpRequest |
HttpRequest.options(CharSequence url)
Start an 'OPTIONS' request to the given URL
|
static HttpRequest |
HttpRequest.options(URL url)
Start an 'OPTIONS' request to the given URL
|
HttpRequest |
HttpRequest.part(String name,
File part)
Write part of a multipart request to the request body
|
HttpRequest |
HttpRequest.part(String name,
InputStream part)
Write part of a multipart request to the request body
|
HttpRequest |
HttpRequest.part(String name,
Number part)
Write part of a multipart request to the request body
|
HttpRequest |
HttpRequest.part(String name,
String filename,
File part)
Write part of a multipart request to the request body
|
HttpRequest |
HttpRequest.part(String name,
String filename,
String part)
Write part of a multipart request to the request body
|
HttpRequest |
HttpRequest.part(String name,
String filename,
String contentType,
File part)
Write part of a multipart request to the request body
|
HttpRequest |
HttpRequest.part(String name,
String filename,
String contentType,
InputStream part)
Write part of a multipart request to the request body
|
HttpRequest |
HttpRequest.part(String name,
String filename,
String contentType,
String part)
Write part of a multipart request to the request body
|
HttpRequest |
HttpRequest.partHeader(String name,
String value)
Write a multipart header to the response body
|
static HttpRequest |
HttpRequest.post(CharSequence url)
Start a 'POST' request to the given URL
|
static HttpRequest |
HttpRequest.post(URL url)
Start a 'POST' request to the given URL
|
static HttpRequest |
HttpRequest.put(CharSequence url)
Start a 'PUT' request to the given URL
|
static HttpRequest |
HttpRequest.put(URL url)
Start a 'PUT' request to the given URL
|
InputStreamReader |
HttpRequest.reader()
Get reader to response body using the character set returned from
HttpRequest.charset() |
InputStreamReader |
HttpRequest.reader(String charset)
Get reader to response body using given character set.
|
HttpRequest |
HttpRequest.receive(Appendable appendable)
Receive response into the given appendable
|
HttpRequest |
HttpRequest.receive(File file)
Stream response body to file
|
HttpRequest |
HttpRequest.receive(PrintStream output)
Stream response to given print stream
|
HttpRequest |
HttpRequest.receive(Writer writer)
Receive response into the given writer
|
HttpRequest |
HttpRequest.send(byte[] input)
Write byte array to request body
|
HttpRequest |
HttpRequest.send(CharSequence value)
Write char sequence to request body
The charset configured via
HttpRequest.contentType(String) will be used and
UTF-8 will be used if it is unset. |
HttpRequest |
HttpRequest.send(File input)
Write contents of file to request body
|
HttpRequest |
HttpRequest.send(InputStream input)
Write stream to request body
The given stream will be closed once sending completes
|
HttpRequest |
HttpRequest.send(Reader input)
Write reader to request body
The given reader will be closed once sending completes
|
boolean |
HttpRequest.serverError()
Is the response code a 500 Internal Server Error?
|
InputStream |
HttpRequest.stream()
Get stream to response body
|
static HttpRequest |
HttpRequest.trace(CharSequence url)
Start a 'TRACE' request to the given URL
|
static HttpRequest |
HttpRequest.trace(URL url)
Start a 'TRACE' request to the given URL
|
HttpRequest |
HttpRequest.trustAllCerts()
Configure HTTPS connection to trust all certificates
This method does nothing if the current request is not a HTTPS request
|
OutputStreamWriter |
HttpRequest.writer()
Create writer to request output stream
|
| 构造器和说明 |
|---|
HttpRequest(CharSequence url,
String method)
Create HTTP connection wrapper
|
HttpRequest(URL url,
String method)
Create HTTP connection wrapper
|
Copyright © 2023. All rights reserved.