public class HttpRequest extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
DOS_PREVENTION_HEADER
Automatically added to every request so that we know that the request came from our server.
|
| Constructor and Description |
|---|
HttpRequest(HttpRequest request)
Clone an existing HttpRequest.
|
HttpRequest(Uri uri)
Construct a new request for the given uri.
|
| Modifier and Type | Method and Description |
|---|---|
HttpRequest |
addAllHeaders(Map<String,? extends List<String>> headers)
Adds all headers in the provided map to the request.
|
HttpRequest |
addHeader(String name,
String value)
Add a single header to the request.
|
HttpRequest |
addHeaders(Map<String,String> headers)
Adds an entire map of headers to the request.
|
boolean |
equals(Object obj) |
AuthType |
getAuthType() |
int |
getCacheTtl() |
String |
getContainer() |
String |
getContentType() |
boolean |
getFollowRedirects() |
Uri |
getGadget() |
String |
getHeader(String name) |
Map<String,List<String>> |
getHeaders() |
List<String> |
getHeaders(String name) |
boolean |
getIgnoreCache() |
String |
getMethod() |
OAuthArguments |
getOAuthArguments() |
String |
getParam(String paramName) |
Integer |
getParamAsInteger(String paramName) |
Map<String,String> |
getParams() |
InputStream |
getPostBody() |
String |
getPostBodyAsString() |
int |
getPostBodyLength()
Retrieves the total length of the post body.
|
String |
getRewriteMimeType() |
SecurityToken |
getSecurityToken() |
Uri |
getUri() |
int |
hashCode() |
boolean |
isCajaRequested()
Should content fetched in response to this request
be sanitized based on the specified mime-type
|
boolean |
isSanitizationRequested()
Should content fetched in response to this request
be sanitized based on the specified mime-type
|
List<String> |
removeHeader(String name)
Remove all headers with the given name from the request.
|
HttpRequest |
setAuthType(AuthType authType) |
HttpRequest |
setCacheTtl(int cacheTtl) |
void |
setCajaRequested(boolean cajaRequested) |
HttpRequest |
setContainer(String container) |
HttpRequest |
setFollowRedirects(boolean followRedirects) |
HttpRequest |
setGadget(Uri gadget) |
HttpRequest |
setHeader(String name,
String value)
Sets a single header value, overwriting any previously set headers with the same name.
|
HttpRequest |
setIgnoreCache(boolean ignoreCache) |
HttpRequest |
setMethod(String method) |
HttpRequest |
setOAuthArguments(OAuthArguments oauthArguments) |
<T> void |
setParam(String paramName,
T paramValue) |
HttpRequest |
setPostBody(byte[] postBody)
Assigns the specified body to the request, copying all input bytes.
|
HttpRequest |
setPostBody(InputStream is)
Fills in the request body from an InputStream.
|
HttpRequest |
setRewriteMimeType(String rewriteMimeType) |
void |
setSanitizationRequested(boolean sanitizationRequested) |
HttpRequest |
setSecurityToken(SecurityToken securityToken)
Assign the security token to use for making any form of authenticated request.
|
HttpRequest |
setUri(Uri uri) |
String |
toString() |
public static final String DOS_PREVENTION_HEADER
public HttpRequest(Uri uri)
public HttpRequest(HttpRequest request)
public HttpRequest setMethod(String method)
public HttpRequest setUri(Uri uri)
public HttpRequest addHeader(String name, String value)
setHeader(String, String).public HttpRequest setHeader(String name, String value)
public HttpRequest addHeaders(Map<String,String> headers)
public HttpRequest addAllHeaders(Map<String,? extends List<String>> headers)
public List<String> removeHeader(String name)
public HttpRequest setPostBody(byte[] postBody)
public HttpRequest setPostBody(InputStream is) throws IOException
IOExceptionpublic HttpRequest setIgnoreCache(boolean ignoreCache)
ignoreCache - Whether to ignore all caching for this request.public boolean isSanitizationRequested()
public void setSanitizationRequested(boolean sanitizationRequested)
public boolean isCajaRequested()
public void setCajaRequested(boolean cajaRequested)
public HttpRequest setCacheTtl(int cacheTtl)
cacheTtl - The amount of time to cache the result object for, in seconds. If set to -1,
HTTP cache control headers will be honored. Otherwise objects will be cached for the time
specified.public HttpRequest setGadget(Uri gadget)
gadget - The gadget that caused this HTTP request to be necessary. May be null if the
request was not initiated by the actions of a gadget.public HttpRequest setContainer(String container)
container - The container that this request originated from.public HttpRequest setSecurityToken(SecurityToken securityToken)
public HttpRequest setOAuthArguments(OAuthArguments oauthArguments)
oauthArguments - arguments for OAuth/signed fetchedpublic HttpRequest setFollowRedirects(boolean followRedirects)
followRedirects - whether this request should automatically follow redirects.public HttpRequest setAuthType(AuthType authType)
authType - The type of authentication being used for this request.public HttpRequest setRewriteMimeType(String rewriteMimeType)
rewriteMimeType - The assumed content type of the response to be rewritten. Overrides
any values set in the Content-Type response header.
TODO: Move this to new rewriting facility.public String getMethod()
public Uri getUri()
public Map<String,List<String>> getHeaders()
public List<String> getHeaders(String name)
name - The header to fetchpublic String getHeader(String name)
public String getContentType()
public InputStream getPostBody()
public String getPostBodyAsString()
public int getPostBodyLength()
public boolean getIgnoreCache()
public int getCacheTtl()
public Uri getGadget()
public <T> void setParam(String paramName, T paramValue)
public String getContainer()
public SecurityToken getSecurityToken()
public OAuthArguments getOAuthArguments()
public boolean getFollowRedirects()
public AuthType getAuthType()
public String getRewriteMimeType()
Copyright © 2007-2012. All Rights Reserved.