Class HTTPRequest
java.lang.Object
com.google.appengine.api.urlfetch.HTTPRequest
- All Implemented Interfaces:
Serializable
HTTPRequest
encapsulates a single HTTP request that is made
via the URLFetchService
.- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionHTTPRequest
(URL url) Creates aHTTPRequest
that represents a GET request to the specified URL.HTTPRequest
(URL url, HTTPMethod method) Creates aHTTPRequest
that represents an HTTP request to the specified URL with the specified HTTP method (GET, POST, etc).HTTPRequest
(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
Modifier and TypeMethodDescriptionvoid
addHeader
(HTTPHeader header) Addsheader
to this request.Get the fetch options for this request.Returns an immutableList
ofHTTPHeader
objects that have been added to this request.Gets the HTTP method for this request (GET, POST, etc).byte @Nullable []
Gets the payload (such as POST body) for this request.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 Details
-
HTTPRequest
Creates aHTTPRequest
that represents a GET request to the specified URL. -
HTTPRequest
Creates aHTTPRequest
that represents an HTTP request to the specified URL with the specified HTTP method (GET, POST, etc). -
HTTPRequest
Creates aHTTPRequest
that represents an HTTP request to the specified URL with the specified HTTP method (GET, POST, etc) and the specifiedFetchOptions
.
-
-
Method Details
-
getMethod
Gets the HTTP method for this request (GET, POST, etc). -
getURL
Gets the URL for this request. -
getPayload
public byte @Nullable [] 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
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
Sets anHTTPHeader
for this request. If anHTTPHeader
with the samename
already exists, its value is replaced. -
getHeaders
Returns an immutableList
ofHTTPHeader
objects that have been added to this request. -
getFetchOptions
Get the fetch options for this request.
-