google.appengine.api.urlfetch.Fetch

Fetches the given HTTP url, blocking until the result is returned.

URLs are fetched using one of the following HTTP methods:

- `GET`
- `POST`
- `HEAD`
- `PUT`
- `DELETE`
- `PATCH`

To fetch the result, a HTTP/1.1-compliant proxy is used.

method The constants GET, POST, HEAD, PUT, DELETE, or PATCH or the same HTTP methods as strings.
payload POST, PUT, or PATCH payload (implies method is not GET, HEAD, or DELETE). This argument is ignored if the method is not POST, PUT, or PATCH.
headers Dictionary of HTTP headers to send with the request.
allow_truncated If set to True, truncates large responses and returns them without raising an error. Otherwise, a ResponseTooLargeError is raised when a response is truncated.
follow_redirects If set to True (the default), redirects are transparently followed. If there are less than five redirects, the response contains the final destination's payload, and the response status is 200. You lose, however, the redirect chain information. If set to False, you see the HTTP response yourself, including the Location header, and redirects are not followed.
deadline Deadline in seconds for the operation.
validate_certificate If set to True, requests are not sent to the server unless the certificate is valid, signed by a trusted CA, and the host name matches the certificate. A value of None (default) indicates that the behavior will be chosen by the underlying urlfetch implementation.

object An object containing following fields:

  • content: A string that contains the response from the server.
  • status_code: The HTTP status code that was returned by the server.
  • headers: The dict of headers that was returned by the server.

urlfetch_errors.Error If an error occurs. See the urlfetch_errors module for more information.

Note:

HTTP errors are returned as a part of the return structure. HTTP errors like 404 do not result in an exception. See urlfetch_errors for details.