Class HTTPRequest
- java.lang.Object
-
- com.google.appengine.api.urlfetch.HTTPRequest
-
- All Implemented Interfaces:
Serializable
public class HTTPRequest extends Object implements Serializable
HTTPRequestencapsulates a single HTTP request that is made via theURLFetchService.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description HTTPRequest(URL url)Creates aHTTPRequestthat represents a GET request to the specified URL.HTTPRequest(URL url, HTTPMethod method)Creates aHTTPRequestthat represents an HTTP request to the specified URL with the specified HTTP method (GET, POST, etc).HTTPRequest(URL url, HTTPMethod method, FetchOptions fetchOptions)Creates aHTTPRequestthat 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 Description voidaddHeader(HTTPHeader header)Addsheaderto this request.FetchOptionsgetFetchOptions()Get the fetch options for this request.List<HTTPHeader>getHeaders()Returns an immutableListofHTTPHeaderobjects that have been added to this request.HTTPMethodgetMethod()Gets the HTTP method for this request (GET, POST, etc).byte @Nullable []getPayload()Gets the payload (such as POST body) for this request.URLgetURL()Gets the URL for this request.voidsetHeader(HTTPHeader header)Sets anHTTPHeaderfor this request.voidsetPayload(byte[] payload)Sets the payload for this request.
-
-
-
Constructor Detail
-
HTTPRequest
public HTTPRequest(URL url)
Creates aHTTPRequestthat represents a GET request to the specified URL.
-
HTTPRequest
public HTTPRequest(URL url, HTTPMethod method)
Creates aHTTPRequestthat represents an HTTP request to the specified URL with the specified HTTP method (GET, POST, etc).
-
HTTPRequest
public HTTPRequest(URL url, HTTPMethod method, FetchOptions fetchOptions)
Creates aHTTPRequestthat 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 URL 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
public void addHeader(HTTPHeader header)
Addsheaderto this request. If anHTTPHeaderwith the samenamealready exists for this request, it's values are merged withheader.- Parameters:
header- a notnullHTTPHeader
-
setHeader
public void setHeader(HTTPHeader header)
Sets anHTTPHeaderfor this request. If anHTTPHeaderwith the samenamealready exists, its value is replaced.
-
getHeaders
public List<HTTPHeader> getHeaders()
Returns an immutableListofHTTPHeaderobjects that have been added to this request.
-
getFetchOptions
public FetchOptions getFetchOptions()
Get the fetch options for this request.
-
-