public class HttpConnection extends Object implements Connection
Connection.| 限定符和类型 | 类和说明 |
|---|---|
static class |
HttpConnection.KeyVal |
static class |
HttpConnection.Request |
static class |
HttpConnection.Response |
Connection.Method| 限定符和类型 | 方法和说明 |
|---|---|
static Connection |
connect(String url) |
static Connection |
connect(URL url) |
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.
|
public static Connection connect(String url)
public static Connection connect(URL url)
public Connection url(URL url)
Connectionurl 在接口中 Connectionurl - URL to connect topublic Connection url(String url)
Connectionurl 在接口中 Connectionurl - URL to connect topublic Connection userAgent(String userAgent)
ConnectionuserAgent 在接口中 ConnectionuserAgent - user-agent to usepublic Connection timeout(int millis)
Connectiontimeout 在接口中 Connectionmillis - number of milliseconds (thousandths of a second) before timing out connects or reads.public Connection followRedirects(boolean followRedirects)
ConnectionfollowRedirects 在接口中 ConnectionfollowRedirects - true if server redirects should be followed.public Connection referrer(String referrer)
Connectionreferrer 在接口中 Connectionreferrer - referrer to usepublic Connection method(Connection.Method method)
Connectionmethod 在接口中 Connectionmethod - HTTP request methodpublic Connection data(String key, String value)
Connectiondata 在接口中 Connectionkey - data keyvalue - data valuepublic Connection data(Map<String,String> data)
Connectiondata 在接口中 Connectiondata - map of data parameterspublic Connection data(String... keyvals)
Connection.data("name", "jsoup", "language", "Java", "language", "English"); creates a query string like:data 在接口中 Connectionkeyvals - a set of key value pairs.public Connection header(String name, String value)
Connectionheader 在接口中 Connectionname - header namevalue - header valuepublic Connection cookie(String name, String value)
Connectioncookie 在接口中 Connectionname - name of cookievalue - value of cookiepublic Connection.Response execute() throws IOException
Connectionexecute 在接口中 ConnectionIOException - on errorpublic Connection.Request request()
Connectionrequest 在接口中 Connectionpublic Connection request(Connection.Request request)
Connectionrequest 在接口中 Connectionrequest - new request objectpublic Connection.Response response()
Connectionresponse 在接口中 Connectionpublic Connection response(Connection.Response response)
Connectionresponse 在接口中 Connectionresponse - new responseCopyright © 2021. All rights reserved.