com.google.appengine.api.urlfetch
Class HTTPRequest
- java.lang.Object
-
- com.google.appengine.api.urlfetch.HTTPRequest
-
- All Implemented Interfaces:
- java.io.Serializable
public class HTTPRequest extends java.lang.Object implements java.io.Serializable
HTTPRequest
encapsulates a single HTTP request that is made via theURLFetchService
.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description HTTPRequest(java.net.URL url)
Creates aHTTPRequest
that represents a GET request to the specified URL.HTTPRequest(java.net.URL url, HTTPMethod method)
Creates aHTTPRequest
that represents an HTTP request to the specified URL with the specified HTTP method (GET, POST, etc).HTTPRequest(java.net.URL url, HTTPMethod method, FetchOptions fetchOptions)
Creates aHTTPRequest
that represents an HTTP request to the specified URL with the specified HTTP method (GET, POST, etc) and the specifiedFetchOptions
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description void
addHeader(HTTPHeader header)
Addsheader
to this request.FetchOptions
getFetchOptions()
Get the fetch options for this request.java.util.List<HTTPHeader>
getHeaders()
Returns an immutableList
ofHTTPHeader
objects that have been added to this request.HTTPMethod
getMethod()
Gets the HTTP method for this request (GET, POST, etc).byte[]
getPayload()
Gets the payload (such as POST body) for this request.java.net.URL
getURL()
Gets the URL for this request.void
setHeader(HTTPHeader header)
Sets anHTTPHeader
for this request.void
setPayload(byte[] payload)
Sets the payload for this request.
-
-
-
Constructor Detail
-
HTTPRequest
public HTTPRequest(java.net.URL url)
Creates aHTTPRequest
that represents a GET request to the specified URL.
-
HTTPRequest
public HTTPRequest(java.net.URL url, HTTPMethod method)
Creates aHTTPRequest
that represents an HTTP request to the specified URL with the specified HTTP method (GET, POST, etc).
-
HTTPRequest
public HTTPRequest(java.net.URL url, HTTPMethod method, FetchOptions fetchOptions)
Creates aHTTPRequest
that represents an HTTP request to the specified URL with the specified HTTP method (GET, POST, etc) and the specifiedFetchOptions
.
-
-
Method Detail
-
getMethod
public HTTPMethod getMethod()
Gets the HTTP method for this request (GET, POST, etc).
-
getURL
public java.net.URL getURL()
Gets the URL for this request.
-
getPayload
public byte[] getPayload()
Gets the payload (such as POST body) for this request. Certain HTTP methods (e.g. GET) will not have any payload, and this method will return null.
-
setPayload
public void setPayload(byte[] payload)
Sets the payload for this request. This method should not be called for certain HTTP methods (e.g. GET).
-
addHeader
public void addHeader(HTTPHeader header)
Addsheader
to this request. If anHTTPHeader
with the samename
already exists for this request, it's values are merged withheader
.- Parameters:
header
- a notnull
HTTPHeader
-
setHeader
public void setHeader(HTTPHeader header)
Sets anHTTPHeader
for this request. If anHTTPHeader
with the samename
already exists, its value is replaced.
-
getHeaders
public java.util.List<HTTPHeader> getHeaders()
Returns an immutableList
ofHTTPHeader
objects that have been added to this request.
-
getFetchOptions
public FetchOptions getFetchOptions()
Get the fetch options for this request.
-
-