public final class FetchOptions
extends java.lang.Object
implements java.io.Serializable
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, validate the server's
SSL certificate using the same CA-based algorithm as a typical browser.
HTTP connections are unaffected by this option.
If doNotValidateCertificate() is called the
URLFetchService will not validate the server's SSL certificate
in any fashion.
If neither validateCertificate() nor
doNotValidateCertificate() is called, then the underlying
URLFetchService implementation determines what type of validation
is performed.
Notes on usage:
The recommended way to instantiate a FetchOptions object is to
statically import FetchOptions.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()));
| Modifier and Type | Class and Description |
|---|---|
static class |
FetchOptions.Builder
Contains static creation methods for
FetchOptions. |
| Modifier and Type | Field and Description |
|---|---|
static boolean |
DEFAULT_ALLOW_TRUNCATE |
static java.lang.Double |
DEFAULT_DEADLINE
The default deadline is defined externally.
|
static boolean |
DEFAULT_FOLLOW_REDIRECTS |
| Modifier and Type | Method and Description |
|---|---|
FetchOptions |
allowTruncate()
Enables response truncation.
|
FetchOptions |
disallowTruncate()
Disables response truncation.
|
FetchOptions |
doNotFollowRedirects()
Disables following of redirects.
|
FetchOptions |
doNotValidateCertificate()
Disables certificate validation on HTTPS connections.
|
FetchOptions |
followRedirects()
Enables following of redirects.
|
FetchOptions |
setDeadline(java.lang.Double deadline)
Sets the deadline, in seconds, for the fetch request.
|
FetchOptions |
validateCertificate()
Enables certificate validation on HTTPS connections via the normal
CA-based mechanism.
|
public static final boolean DEFAULT_ALLOW_TRUNCATE
public static final boolean DEFAULT_FOLLOW_REDIRECTS
public static final java.lang.Double DEFAULT_DEADLINE
public FetchOptions allowTruncate()
this (for chaining)public FetchOptions disallowTruncate()
this (for chaining)public FetchOptions followRedirects()
this (for chaining)public FetchOptions validateCertificate()
this (for chaining)public FetchOptions doNotValidateCertificate()
this (for chaining)public FetchOptions setDeadline(java.lang.Double deadline)
this (for chaining)java.lang.IllegalArgumentException - if deadline is not positivepublic FetchOptions doNotFollowRedirects()
this (for chaining)