public class WebRequest extends Object implements Serializable
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)
Instantiates a
WebRequest for the specified URL. |
Modifier and Type | Method and Description |
---|---|
Map<String,String> |
getAdditionalHeaders()
Returns the additional HTTP headers to use.
|
String |
getCharset()
Returns the character set to use to perform the request.
|
org.apache.http.auth.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.
|
org.apache.http.auth.Credentials |
getUrlCredentials()
Returns the credentials to use.
|
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.
|
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(String charset)
Sets the character set to use to perform the request.
|
void |
setCredentials(org.apache.http.auth.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)
WebRequest
for the specified URL.url
- the target URLacceptHeader
- the accept 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 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 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 org.apache.http.auth.Credentials getUrlCredentials()
public org.apache.http.auth.Credentials getCredentials()
public void setCredentials(org.apache.http.auth.Credentials credentials)
credentials
- the credentials to usepublic String getCharset()
public void setCharset(String charset)
TextUtil.DEFAULT_CHARSET
.charset
- the character set to use to perform the requestCopyright © 2002–2017 Gargoyle Software Inc.. All rights reserved.