com.google.appengine.api.urlfetch.FetchOptions

Here are the examples of the java api class com.google.appengine.api.urlfetch.FetchOptions taken from open source projects.

1. GaeRequestHandler#handle()

View license
@Override
public <T, R extends ApiResponse<T>> PendingResult<T> handle(String hostName, String url, String userAgent, Class<R> clazz, FieldNamingPolicy fieldNamingPolicy, long errorTimeout) {
    FetchOptions fetchOptions = FetchOptions.Builder.withDeadline(10);
    HTTPRequest req = null;
    try {
        req = new HTTPRequest(new URL(hostName + url), HTTPMethod.POST, fetchOptions);
    } catch (MalformedURLException e) {
        LOG.log(Level.SEVERE, String.format("Request: %s%s", hostName, url), e);
        throw (new RuntimeException(e));
    }
    return new GaePendingResult<T, R>(req, client, clazz, fieldNamingPolicy, errorTimeout);
}

2. UrlFetchTransport#buildRequest()

View license
@Override
protected UrlFetchRequest buildRequest(String method, String url) throws IOException {
    Preconditions.checkArgument(supportsMethod(method), "HTTP method %s not supported", method);
    HTTPMethod httpMethod;
    if (method.equals(HttpMethods.DELETE)) {
        httpMethod = HTTPMethod.DELETE;
    } else if (method.equals(HttpMethods.GET)) {
        httpMethod = HTTPMethod.GET;
    } else if (method.equals(HttpMethods.HEAD)) {
        httpMethod = HTTPMethod.HEAD;
    } else if (method.equals(HttpMethods.POST)) {
        httpMethod = HTTPMethod.POST;
    } else if (method.equals(HttpMethods.PATCH)) {
        httpMethod = HTTPMethod.PATCH;
    } else {
        httpMethod = HTTPMethod.PUT;
    }
    // fetch options
    FetchOptions fetchOptions = FetchOptions.Builder.doNotFollowRedirects().disallowTruncate().validateCertificate();
    switch(certificateValidationBehavior) {
        case VALIDATE:
            fetchOptions.validateCertificate();
            break;
        case DO_NOT_VALIDATE:
            fetchOptions.doNotValidateCertificate();
            break;
        default:
            break;
    }
    return new UrlFetchRequest(fetchOptions, httpMethod, url);
}