@Override public <T, R extends ApiResponse<T>> PendingResult<T> handle( String hostName, String url, String userAgent, Class<R> clazz, FieldNamingPolicy fieldNamingPolicy, long errorTimeout, Integer maxRetries, ExceptionsAllowedToRetry exceptionsAllowedToRetry) { FetchOptions fetchOptions = FetchOptions.Builder.withDeadline(10); HTTPRequest req; try { req = new HTTPRequest(new URL(hostName + url), HTTPMethod.POST, fetchOptions); } catch (MalformedURLException e) { LOG.error("Request: {}{}", hostName, url, e); throw (new RuntimeException(e)); } return new GaePendingResult<>( req, client, clazz, fieldNamingPolicy, errorTimeout, maxRetries, exceptionsAllowedToRetry); }
@Override public <T, R extends ApiResponse<T>> PendingResult<T> handlePost( String hostName, String url, String payload, String userAgent, Class<R> clazz, FieldNamingPolicy fieldNamingPolicy, long errorTimeout, Integer maxRetries, ExceptionsAllowedToRetry exceptionsAllowedToRetry) { FetchOptions fetchOptions = FetchOptions.Builder.withDeadline(10); HTTPRequest req = null; try { req = new HTTPRequest(new URL(hostName + url), HTTPMethod.POST, fetchOptions); req.setHeader(new HTTPHeader("Content-Type", "application/json; charset=utf-8")); 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); }
@Override public <T, R extends ApiResponse<T>> PendingResult<T> handle( String hostName, String url, String userAgent, Class<R> clazz, FieldNamingPolicy fieldNamingPolicy, long errorTimeout, Integer maxRetries, ExceptionsAllowedToRetry exceptionsAllowedToRetry) { FetchOptions fetchOptions = FetchOptions.Builder.withDeadline(10); HTTPRequest req; try { req = new HTTPRequest(new URL(hostName + url), HTTPMethod.POST, fetchOptions); } catch (MalformedURLException e) { LOG.error("Request: {}{}", hostName, url, e); throw (new RuntimeException(e)); } return new GaePendingResult<>( req, client, clazz, fieldNamingPolicy, errorTimeout, maxRetries, exceptionsAllowedToRetry); }
FetchOptions fetchOptions = FetchOptions.Builder.withDeadline(config .getReadTimeout() / 1000).validateCertificate(); HTTPRequest request = new HTTPRequest(url, HTTPMethod.POST, fetchOptions);
FetchOptions fetchOptions = FetchOptions.Builder.withDeadline(config .getReadTimeout() / 1000).validateCertificate(); HTTPRequest request = new HTTPRequest(url, HTTPMethod.POST, fetchOptions);
@Override public <T, R extends ApiResponse<T>> PendingResult<T> handlePost( String hostName, String url, String payload, String userAgent, Class<R> clazz, FieldNamingPolicy fieldNamingPolicy, long errorTimeout, Integer maxRetries, ExceptionsAllowedToRetry exceptionsAllowedToRetry) { FetchOptions fetchOptions = FetchOptions.Builder.withDeadline(10); HTTPRequest req = null; try { req = new HTTPRequest(new URL(hostName + url), HTTPMethod.POST, fetchOptions); req.setHeader(new HTTPHeader("Content-Type", "application/json; charset=utf-8")); 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); }
@Test public void testWithDeadline() throws Exception { FetchOptions options = FetchOptions.Builder.withDeadline(10 * 1000.0); testOptions(options); }