@Override protected ClientHttpRequest createRequest(URI uri, HttpMethod httpMethod, ClientHttpRequestFactory requestFactory) throws IOException { ClientHttpRequest request = requestFactory.createRequest(uri, httpMethod); if (shouldBuffer(uri, httpMethod)) { return new BufferingClientHttpRequestWrapper(request); } else { return request; } }
@Override public void onResponse(Call call, Response response) { set(new OkHttp3ClientHttpResponse(response)); } @Override
@Override public final OutputStream getBody() throws IOException { assertNotExecuted(); return getBodyInternal(this.headers); }
@Override public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException { return execution.execute(new HttpRequestWrapper(request) { @Override public URI getURI() { return changedUri; } }, body); } };
@SuppressWarnings("deprecation") @Parameters public static Iterable<? extends ClientHttpRequestFactory> data() { return Arrays.asList( new SimpleClientHttpRequestFactory(), new HttpComponentsClientHttpRequestFactory(), new Netty4ClientHttpRequestFactory(), new OkHttp3ClientHttpRequestFactory() ); }
@Override protected ClientHttpRequestFactory createRequestFactory() { HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(); requestFactory.setBufferRequestBody(false); return new InterceptingClientHttpRequestFactory(requestFactory, null); }
@Override protected ClientHttpRequestFactory createRequestFactory() { return new BufferingClientHttpRequestFactory(new HttpComponentsClientHttpRequestFactory()); }
@Override public HttpHeaders extractData(ClientHttpResponse response) { return response.getHeaders(); } }
@Override protected ClientHttpRequestFactory createRequestFactory() { SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory(); factory.setBufferRequestBody(false); factory.setOutputStreaming(false); return factory; } }
@Override protected ClientHttpResponse executeInternal(HttpHeaders headers) throws IOException { HttpComponentsClientHttpRequest.addHeaders(this.httpRequest, headers); if (this.httpRequest instanceof HttpEntityEnclosingRequest && this.body != null) { HttpEntityEnclosingRequest entityEnclosingRequest = (HttpEntityEnclosingRequest) this.httpRequest; HttpEntity requestEntity = new StreamingHttpEntity(getHeaders(), this.body); entityEnclosingRequest.setEntity(requestEntity); } HttpResponse httpResponse = this.httpClient.execute(this.httpRequest, this.httpContext); return new HttpComponentsClientHttpResponse(httpResponse); }
/** * Add a part from an Object. * @param name the name of the part to add * @param part the part data * @return builder that allows for further customization of part headers */ public PartBuilder part(String name, Object part) { return part(name, part, null); }
@Override public final OutputStream getBody() throws IOException { assertNotExecuted(); return getBodyInternal(this.headers); }
@Override protected ListenableFuture<ClientHttpResponse> executeInternal(HttpHeaders headers, byte[] body) throws IOException { return new AsyncRequestExecution().executeAsync(this, body); }
@Override public HttpHeaders getHeaders() { return request.getHeaders(); } });
@SuppressWarnings("deprecation") @Override protected AsyncClientHttpRequestFactory createRequestFactory() { return new Netty4ClientHttpRequestFactory(eventLoopGroup); }
@Override public OutputStream getBody() throws IOException { return request.getBody(); } @Override
@Override public void setBody(Body body) { assertNotExecuted(); this.body = body; }
@Override public <T, P extends Publisher<T>> MultipartInserter withPublisher( String name, P publisher, Class<T> elementClass) { this.builder.asyncPart(name, publisher, elementClass); return this; }
@Override public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException { return execution.execute(new HttpRequestWrapper(request) { @Override public HttpMethod getMethod() { return changedMethod; } }, body); } };
@Override public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException { invoked = true; return execution.execute(request, body); } }