Provides a service to make HTTP/S requests of other servers on the internet. The java.net.URLConnection class can also be used to do this, and in App Engine is implemented by using URL Fetch. Chunked and hanging requests, however, are not supported.
As is typical for App Engine services, the URLFetchServiceFactory returns a URLFetchService, which is used to actually make requests of the service. See Also: The URL Fetch Java API in the Google App Engine Developer's Guide., com.google.appengine.api.urlfetch.URLFetchService
Classes
FetchOptions
Allows users to customize the behavior of URLFetchService operations.
If #allowTruncate() is called, URLFetchService will truncate large responses and return them without error.
If #disallowTruncate is called, ResponseTooLargeException will be thrown if the response is too large.
If #followRedirects() is called the URLFetchService operation will follow redirects.
If #doNotFollowRedirects() is called the URLFetchService operation will not follow redirects.
If #validateCertificate() is called the URLFetchService operation will, if using an HTTPS connection, instruct the application to send a request to the server only if the certificate is valid and signed by a trusted certificate authority (CA), and also includes a hostname that matches the certificate. If the certificate validation fails, a javax.net.ssl.SSLHandshakeException exception is thrown. HTTP connections are unaffected by this option.
If #doNotValidateCertificate() is called the URLFetchService will not validate the server's SSL certificate in any fashion. This is the default behavior. Note, however, that validation will be turned on by default in the near future. If you rely upon making requests to a site with an invalid or untrusted certificate, you should explicitly call #doNotValidateCertificate() to avoid errors in future versions.
Notes on usage:
The recommended way to instantiate a FetchOptions
object is to
statically import Builder.* and invoke a static
creation method followed by an instance mutator (if needed):
import static com.google.appengine.api.urlfetch.FetchOptions.Builder.*;
...
URL url = getURLToFetch();
urlFetchService.fetch(new HTTPRequest(url, HTTPMethod.GET,
allowTruncate()));
urlFetchService.fetch(new HTTPRequest(url, HTTPMethod.GET,
allowTruncate().doNotFollowRedirects()));
FetchOptions.Builder
Contains static creation methods for FetchOptions.
HTTPHeader
HTTPHeader
can represent either an HTTP request header, or
an HTTP response header.
HTTPRequest
HTTPRequest
encapsulates a single HTTP request that is made
via the URLFetchService
.
HTTPResponse
HTTPResponse
encapsulates the results of a
HTTPRequest
made via the URLFetchService
.
IURLFetchServiceFactoryProvider
Factory provider for IURLFetchServiceFactory.
Note: This class is not intended for end users.
URLFetchServiceFactory
Factory for URLFetchService
URLFetchServicePb
URLFetchServicePb.URLFetchRequest
URLFetchServicePb.URLFetchRequest.Builder
URLFetchServicePb.URLFetchRequest.Header
URLFetchServicePb.URLFetchRequest.Header.Builder
URLFetchServicePb.URLFetchResponse
URLFetchServicePb.URLFetchResponse.Builder
URLFetchServicePb.URLFetchResponse.Header
URLFetchServicePb.URLFetchResponse.Header.Builder
URLFetchServicePb.URLFetchServiceError
URLFetchServicePb.URLFetchServiceError.Builder
Interfaces
IURLFetchServiceFactory
Factory for URLFetchService
URLFetchService
The URLFetchService
provides a way for user code to execute
HTTP requests to external URLs.
Chunked and hanging requests are not supported, and all content will be returned in a single block.
URLFetchServicePb.URLFetchRequest.HeaderOrBuilder
URLFetchServicePb.URLFetchRequestOrBuilder
URLFetchServicePb.URLFetchResponse.HeaderOrBuilder
URLFetchServicePb.URLFetchResponseOrBuilder
URLFetchServicePb.URLFetchServiceErrorOrBuilder
Enums
HTTPMethod
HTTPMethod
is an enumeration of HTTP methods that can be
sent to a remote server via the URLFetchService
.
URLFetchServicePb.URLFetchRequest.RequestMethod
URLFetchServicePb.URLFetchServiceError.ErrorCode
Exceptions
InternalTransientException
InternalTransientException
is thrown when
a temporary error occurs in retrieving the URL.
RequestPayloadTooLargeException
RequestPayloadTooLargeException
is thrown when the payload of a URLFetchService
request is too large.
This is a subclass of MalformedURLException for backwards compatibility as it is thrown in places where MalformedURLException was thrown previously.
ResponseTooLargeException
ResponseTooLargeException
is thrown when the result of a
URLFetchService operation is too large.