Class FetchOptions
- java.lang.Object
-
- com.google.appengine.api.urlfetch.FetchOptions
-
- All Implemented Interfaces:
- java.io.Serializable
public final class FetchOptions extends java.lang.Object implements java.io.SerializableAllows users to customize the behavior ofURLFetchServiceoperations.If
allowTruncate()is called,URLFetchServicewill truncate large responses and return them without error.If
disallowTruncate()is called,ResponseTooLargeExceptionwill be thrown if the response is too large.If
followRedirects()is called theURLFetchServiceoperation will follow redirects.If
doNotFollowRedirects()is called theURLFetchServiceoperation will not follow redirects.If
validateCertificate()is called theURLFetchServiceoperation 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, aSSLHandshakeExceptionexception is thrown. HTTP connections are unaffected by this option.If
doNotValidateCertificate()is called theURLFetchServicewill 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 calldoNotValidateCertificate()to avoid errors in future versions.Notes on usage:
The recommended way to instantiate aFetchOptionsobject is to statically importFetchOptions.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:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static classFetchOptions.BuilderContains static creation methods forFetchOptions.
-
Field Summary
Fields Modifier and Type Field and Description static booleanDEFAULT_ALLOW_TRUNCATEstatic java.lang.DoubleDEFAULT_DEADLINEThe default deadline is 5 seconds.static booleanDEFAULT_FOLLOW_REDIRECTS
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description FetchOptionsallowTruncate()Enables response truncation.FetchOptionsdisallowTruncate()Disables response truncation.FetchOptionsdoNotFollowRedirects()Disables following of redirects.FetchOptionsdoNotValidateCertificate()Disables certificate validation on HTTPS connections.FetchOptionsfollowRedirects()Enables following of redirects.booleangetAllowTruncate()java.lang.DoublegetDeadline()booleangetFollowRedirects()booleangetValidateCertificate()FetchOptionssetDeadline(java.lang.Double deadline)Sets the deadline, in seconds, for the fetch request.FetchOptionsvalidateCertificate()Enables certificate validation on HTTPS connections via the normal CA-based mechanism.
-
-
-
Field Detail
-
DEFAULT_ALLOW_TRUNCATE
public static final boolean DEFAULT_ALLOW_TRUNCATE
- See Also:
- Constant Field Values
-
DEFAULT_FOLLOW_REDIRECTS
public static final boolean DEFAULT_FOLLOW_REDIRECTS
- See Also:
- Constant Field Values
-
DEFAULT_DEADLINE
public static final java.lang.Double DEFAULT_DEADLINE
The default deadline is 5 seconds.
-
-
Method Detail
-
allowTruncate
public FetchOptions allowTruncate()
Enables response truncation. Please read the class javadoc for an explanation of how allowTruncate is used.- Returns:
this(for chaining)
-
disallowTruncate
public FetchOptions disallowTruncate()
Disables response truncation. Please read the class javadoc for an explanation of how allowTruncate is used.- Returns:
this(for chaining)
-
followRedirects
public FetchOptions followRedirects()
Enables following of redirects. Please read the class javadoc for an explanation of how followRedirects is used.- Returns:
this(for chaining)
-
validateCertificate
public FetchOptions 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
public FetchOptions 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
public FetchOptions setDeadline(java.lang.Double deadline)
Sets the deadline, in seconds, for the fetch request.- Returns:
this(for chaining)- Throws:
java.lang.IllegalArgumentException- if deadline is not positive
-
doNotFollowRedirects
public FetchOptions 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
public java.lang.Double getDeadline()
-
getValidateCertificate
public boolean getValidateCertificate()
-
-