public class WebRequest extends Object implements Serializable
| Modifier and Type | Class and Description |
|---|---|
static class |
WebRequest.HttpHint |
| Constructor and Description |
|---|
WebRequest(URL url)
Instantiates a
WebRequest for the specified URL. |
WebRequest(URL url,
HttpMethod submitMethod)
Instantiates a
WebRequest for the specified URL using the specified HTTP submit method. |
WebRequest(URL url,
String acceptHeader,
String acceptEncodingHeader)
Instantiates a
WebRequest for the specified URL. |
| Modifier and Type | Method and Description |
|---|---|
void |
addHint(WebRequest.HttpHint hint) |
String |
getAdditionalHeader(String name)
Returns the header value associated with this name.
|
Map<String,String> |
getAdditionalHeaders()
Returns the additional HTTP headers to use.
|
Charset |
getCharset()
Returns the character set to use to perform the request.
|
Credentials |
getCredentials()
Returns the credentials to use.
|
FormEncodingType |
getEncodingType()
Returns the form encoding type to use.
|
HttpMethod |
getHttpMethod()
Returns the HTTP submit method to use.
|
String |
getProxyHost()
Returns the proxy host to use.
|
int |
getProxyPort()
Returns the proxy port to use.
|
String |
getRequestBody()
Returns the body content to be submitted if this is a POST request.
|
List<NameValuePair> |
getRequestParameters()
Retrieves the request parameters to use.
|
URL |
getUrl()
Returns the target URL.
|
Credentials |
getUrlCredentials()
Returns the credentials to use.
|
boolean |
hasHint(WebRequest.HttpHint hint) |
boolean |
isAdditionalHeader(String name)
Returns whether the specified header name is already included in the additional HTTP headers.
|
boolean |
isSocksProxy()
Returns whether SOCKS proxy or not.
|
static WebRequest |
newAboutBlankRequest() |
void |
removeAdditionalHeader(String name)
Removed the specified name/value pair from the additional HTTP headers.
|
void |
setAdditionalHeader(String name,
String value)
Sets the specified name/value pair in the additional HTTP headers.
|
void |
setAdditionalHeaders(Map<String,String> additionalHeaders)
Sets the additional HTTP headers to use.
|
void |
setCharset(Charset charset)
Sets the character set to use to perform the request.
|
void |
setCredentials(Credentials credentials)
Sets the credentials to use.
|
void |
setEncodingType(FormEncodingType encodingType)
Sets the form encoding type to use.
|
void |
setHttpMethod(HttpMethod submitMethod)
Sets the HTTP submit method to use.
|
void |
setProxyHost(String proxyHost)
Sets the proxy host to use.
|
void |
setProxyPort(int proxyPort)
Sets the proxy port to use.
|
void |
setRequestBody(String requestBody)
Sets the body content to be submitted if this is a
POST, PUT or PATCH request. |
void |
setRequestParameters(List<NameValuePair> requestParameters)
Sets the request parameters to use.
|
void |
setSocksProxy(boolean isSocksProxy)
Sets whether SOCKS proxy or not.
|
void |
setUrl(URL url)
Sets the target URL.
|
String |
toString()
Returns a string representation of this object.
|
public WebRequest(URL url, String acceptHeader, String acceptEncodingHeader)
WebRequest for the specified URL.url - the target URLacceptHeader - the accept header to useacceptEncodingHeader - the accept encoding header to usepublic WebRequest(URL url)
WebRequest for the specified URL.url - the target URLpublic WebRequest(URL url, HttpMethod submitMethod)
WebRequest for the specified URL using the specified HTTP submit method.url - the target URLsubmitMethod - the HTTP submit method to usepublic static WebRequest newAboutBlankRequest()
public URL getUrl()
public void setUrl(URL url)
url - the target URLpublic String getProxyHost()
public void setProxyHost(String proxyHost)
proxyHost - the proxy host to usepublic int getProxyPort()
public void setProxyPort(int proxyPort)
proxyPort - the proxy port to usepublic boolean isSocksProxy()
public void setSocksProxy(boolean isSocksProxy)
isSocksProxy - whether SOCKS proxy or notpublic FormEncodingType getEncodingType()
public void setEncodingType(FormEncodingType encodingType)
encodingType - the form encoding type to usepublic List<NameValuePair> getRequestParameters()
URL. Should not be used in
combination with the request body.public void setRequestParameters(List<NameValuePair> requestParameters) throws RuntimeException
URL. Should not be used in combination
with the request body.requestParameters - the request parameters to useRuntimeException - if the request body has already been setpublic String getRequestBody()
request parameters.public void setRequestBody(String requestBody) throws RuntimeException
POST, PUT or PATCH request.
Ignored for all other request types.
Should not be used in combination with request parameters.requestBody - the body content to be submitted if this is a POST, PUT
or PATCH requestRuntimeException - if the request parameters have already been set
or this is not a POST, PUT or PATCH request.public HttpMethod getHttpMethod()
public void setHttpMethod(HttpMethod submitMethod)
submitMethod - the HTTP submit method to usepublic Map<String,String> getAdditionalHeaders()
public void setAdditionalHeaders(Map<String,String> additionalHeaders)
additionalHeaders - the additional HTTP headers to usepublic boolean isAdditionalHeader(String name)
name - the name of the additional HTTP headerpublic String getAdditionalHeader(String name)
name - the name of the additional HTTP headerpublic void setAdditionalHeader(String name, String value)
name - the name of the additional HTTP headervalue - the value of the additional HTTP headerpublic void removeAdditionalHeader(String name)
name - the name of the additional HTTP headerpublic Credentials getUrlCredentials()
public Credentials getCredentials()
public void setCredentials(Credentials credentials)
credentials - the credentials to usepublic Charset getCharset()
public void setCharset(Charset charset)
StandardCharsets.ISO_8859_1.charset - the character set to use to perform the requestpublic boolean hasHint(WebRequest.HttpHint hint)
public void addHint(WebRequest.HttpHint hint)
Copyright © 2002–2020 Gargoyle Software Inc.. All rights reserved.