public interface Connection
| 限定符和类型 | 接口和说明 |
|---|---|
static interface |
Connection.Base<T extends Connection.Base>
Common methods for Requests and Responses
|
static interface |
Connection.KeyVal
A Key Value tuple.
|
static class |
Connection.Method
GET and POST http methods.
|
static interface |
Connection.Request
Represents a HTTP request.
|
static interface |
Connection.Response
Represents a HTTP response.
|
| 限定符和类型 | 方法和说明 |
|---|---|
Connection |
cookie(String name,
String value)
Set a cookie to be sent in the request
|
Connection |
data(Map<String,String> data)
Adds all of the supplied data to the request data parameters
|
Connection |
data(String... keyvals)
Add a number of request data parameters.
|
Connection |
data(String key,
String value)
Add a request data parameter.
|
Connection.Response |
execute()
Execute the request.
|
Connection |
followRedirects(boolean followRedirects)
Configures the connection to (not) follow server redirects.
|
Connection |
header(String name,
String value)
Set a request header.
|
Connection |
method(Connection.Method method)
Set the request method to use, GET or POST.
|
Connection |
referrer(String referrer)
Set the request referrer (aka "referer") header.
|
Connection.Request |
request()
Get the request object associatated with this connection
|
Connection |
request(Connection.Request request)
Set the connection's request
|
Connection.Response |
response()
Get the response, once the request has been executed
|
Connection |
response(Connection.Response response)
Set the conenction's response
|
Connection |
timeout(int millis)
Set the request timeouts (connect and read).
|
Connection |
url(String url)
Set the request URL to fetch.
|
Connection |
url(URL url)
Set the request URL to fetch.
|
Connection |
userAgent(String userAgent)
Set the request user-agent header.
|
Connection url(URL url)
url - URL to connect toConnection url(String url)
url - URL to connect toConnection userAgent(String userAgent)
userAgent - user-agent to useConnection timeout(int millis)
millis - number of milliseconds (thousandths of a second) before timing out connects or reads.Connection referrer(String referrer)
referrer - referrer to useConnection followRedirects(boolean followRedirects)
followRedirects - true if server redirects should be followed.Connection method(Connection.Method method)
method - HTTP request methodConnection data(String key, String value)
key - data keyvalue - data valueConnection data(Map<String,String> data)
data - map of data parametersConnection data(String... keyvals)
.data("name", "jsoup", "language", "Java", "language", "English"); creates a query string like:keyvals - a set of key value pairs.Connection header(String name, String value)
name - header namevalue - header valueConnection cookie(String name, String value)
name - name of cookievalue - value of cookieConnection.Response execute() throws IOException
IOException - on errorConnection.Request request()
Connection request(Connection.Request request)
request - new request objectConnection.Response response()
Connection response(Connection.Response response)
response - new responseCopyright © 2021. All rights reserved.