Class FetchOptions
- All Implemented Interfaces:
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, 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 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 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()));
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
Contains static creation methods forFetchOptions
. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final boolean
static final @Nullable Double
The default deadline is 5 seconds.static final boolean
-
Method Summary
Modifier and TypeMethodDescriptionEnables response truncation.Disables response truncation.Disables following of redirects.Disables certificate validation on HTTPS connections.Enables following of redirects.boolean
@Nullable Double
boolean
boolean
setDeadline
(Double deadline) Sets the deadline, in seconds, for the fetch request.Enables certificate validation on HTTPS connections via the normal CA-based mechanism.
-
Field Details
-
DEFAULT_ALLOW_TRUNCATE
public static final boolean DEFAULT_ALLOW_TRUNCATE- See Also:
-
DEFAULT_FOLLOW_REDIRECTS
public static final boolean DEFAULT_FOLLOW_REDIRECTS- See Also:
-
DEFAULT_DEADLINE
The default deadline is 5 seconds.
-
-
Method Details
-
allowTruncate
Enables response truncation. Please read the class javadoc for an explanation of how allowTruncate is used.- Returns:
this
(for chaining)
-
disallowTruncate
Disables response truncation. Please read the class javadoc for an explanation of how allowTruncate is used.- Returns:
this
(for chaining)
-
followRedirects
Enables following of redirects. Please read the class javadoc for an explanation of how followRedirects is used.- Returns:
this
(for chaining)
-
validateCertificate
Enables certificate validation on HTTPS connections via the normal CA-based mechanism. Please read the class javadoc for an explanation of how this option affects certificate validation behavior.- Returns:
this
(for chaining)
-
doNotValidateCertificate
Disables certificate validation on HTTPS connections. Please read the class javadoc for an explanation of how this option affects certificate validation behavior.- Returns:
this
(for chaining)
-
setDeadline
Sets the deadline, in seconds, for the fetch request.- Returns:
this
(for chaining)- Throws:
IllegalArgumentException
- if deadline is not positive
-
doNotFollowRedirects
Disables following of redirects. Please read the class javadoc for an explanation of how doNotFollowRedirects is used.- Returns:
this
(for chaining)
-
getAllowTruncate
public boolean getAllowTruncate() -
getFollowRedirects
public boolean getFollowRedirects() -
getDeadline
-
getValidateCertificate
public boolean getValidateCertificate()
-