Search in sources :

Example 11 with ClientRequest

use of org.glassfish.jersey.client.ClientRequest in project jersey by jersey.

the class JettyConnector method translateRequest.

private Request translateRequest(final ClientRequest clientRequest) {
    final HttpMethod method = HttpMethod.fromString(clientRequest.getMethod());
    if (method == null) {
        throw new ProcessingException(LocalizationMessages.METHOD_NOT_SUPPORTED(clientRequest.getMethod()));
    }
    final URI uri = clientRequest.getUri();
    final Request request = client.newRequest(uri);
    request.method(method);
    request.followRedirects(clientRequest.resolveProperty(ClientProperties.FOLLOW_REDIRECTS, true));
    final Object readTimeout = clientRequest.getConfiguration().getProperties().get(ClientProperties.READ_TIMEOUT);
    if (readTimeout != null && readTimeout instanceof Integer && (Integer) readTimeout > 0) {
        request.timeout((Integer) readTimeout, TimeUnit.MILLISECONDS);
    }
    return request;
}
Also used : Request(org.eclipse.jetty.client.api.Request) ClientRequest(org.glassfish.jersey.client.ClientRequest) URI(java.net.URI) HttpMethod(org.eclipse.jetty.http.HttpMethod) ProcessingException(javax.ws.rs.ProcessingException)

Aggregations

ClientRequest (org.glassfish.jersey.client.ClientRequest)11 ProcessingException (javax.ws.rs.ProcessingException)8 ClientResponse (org.glassfish.jersey.client.ClientResponse)6 IOException (java.io.IOException)4 Test (org.junit.Test)4 CompletableFuture (java.util.concurrent.CompletableFuture)3 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)3 Request (org.eclipse.jetty.client.api.Request)3 ByteBufferInputStream (org.glassfish.jersey.internal.util.collection.ByteBufferInputStream)3 HttpResponseBodyPart (com.ning.http.client.HttpResponseBodyPart)2 HttpResponseHeaders (com.ning.http.client.HttpResponseHeaders)2 HttpResponseStatus (com.ning.http.client.HttpResponseStatus)2 Request (com.ning.http.client.Request)2 CancellationException (java.util.concurrent.CancellationException)2 ExecutionException (java.util.concurrent.ExecutionException)2 Client (javax.ws.rs.client.Client)2 Response (javax.ws.rs.core.Response)2 ContentProvider (org.eclipse.jetty.client.api.ContentProvider)2 ContentResponse (org.eclipse.jetty.client.api.ContentResponse)2 Response (org.eclipse.jetty.client.api.Response)2