@Override
  public <T, R extends ApiResponse<T>> PendingResult<T> handlePost(
      String hostName,
      String url,
      String payload,
      Map<String, String> headers,
      Class<R> clazz,
      FieldNamingPolicy fieldNamingPolicy,
      long errorTimeout,
      Integer maxRetries,
      ExceptionsAllowedToRetry exceptionsAllowedToRetry,
      RequestMetrics metrics) {
    FetchOptions fetchOptions = FetchOptions.Builder.withDeadline(10);
    final HTTPRequest req;
    try {
      req = new HTTPRequest(new URL(hostName + url), HTTPMethod.POST, fetchOptions);
      req.setHeader(new HTTPHeader("Content-Type", "application/json; charset=utf-8"));
      headers.forEach(
          (k, v) -> {
            req.addHeader(new HTTPHeader(k, v));
          });
      req.setPayload(payload.getBytes(UTF_8));
    } catch (MalformedURLException e) {
      LOG.error("Request: {}{}", hostName, url, e);
      throw (new RuntimeException(e));
    }

    return new GaePendingResult<>(
        req,
        client,
        clazz,
        fieldNamingPolicy,
        errorTimeout,
        maxRetries,
        exceptionsAllowedToRetry,
        metrics);
  }
A strategy for handling URL requests using Google App Engine's URL Fetch API.

@see com.google.maps.GeoApiContext.RequestHandler
src/main/java/com/google/maps/GaeRequestHandler.java