@Override public String getMethod() { return invocation.getMethod(); }
/** * Create HttpUrlConnection from ClientInvorcation and set request method. * @param request ClientInvocation * @return HttpURLConnection with method {@literal &} url already set * @throws IOException if url or io exceptions */ protected HttpURLConnection createConnection(final ClientInvocation request) throws IOException { HttpURLConnection connection = (HttpURLConnection) request.getUri().toURL().openConnection(); connection.setRequestMethod(request.getMethod()); return connection; }
private static HttpUriRequest buildHttpRequest(ClientInvocation request) { // Writers may change headers. Thus buffer the content before committing the headers. // For simplicity's sake the content is buffered in memory. File-buffering (ZeroCopyConsumer...) would be // possible, but resource management is error-prone. HttpRequestBase httpRequest = createHttpMethod(request.getUri(), request.getMethod()); if (request.getEntity() != null) { byte[] requestContent = requestContent(request); ByteArrayEntity entity = new ByteArrayEntity(requestContent); entity.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, request.getHeaders().getMediaType().toString())); commitHeaders(request, httpRequest); ((HttpEntityEnclosingRequest) httpRequest).setEntity(entity); } else { commitHeaders(request, httpRequest); } return httpRequest; }
@Override public String getMethod() { return invocation.getMethod(); }
@Override public String getMethod() { return invocation.getMethod(); }
request.method(invocation.getMethod()); invocation.getHeaders().asMap().forEach((h, vs) -> vs.forEach(v -> request.header(h, v))); configureTimeout(request);
final HttpRequestBase httpMethod = createHttpMethod(uri, request.getMethod()); final HttpResponse res; try
/** * Create HttpUrlConnection from ClientInvorcation and set request method. * @param request ClientInvocation * @return HttpURLConnection with method {@literal &} url already set * @throws IOException if url or io exceptions */ protected HttpURLConnection createConnection(final ClientInvocation request) throws IOException { HttpURLConnection connection = (HttpURLConnection) request.getUri().toURL().openConnection(); connection.setRequestMethod(request.getMethod()); return connection; }
/** * Create HttpUrlConnection from ClientInvorcation and set request method * @param request ClientInvocation * @return HttpURLConnection with method & url already set * @throws IOException if url or io exceptions */ protected HttpURLConnection createConnection(final ClientInvocation request) throws IOException { HttpURLConnection connection = (HttpURLConnection) request.getUri().toURL().openConnection(); connection.setRequestMethod(request.getMethod()); return connection; }
protected HttpURLConnection createConnection(ClientInvocation request) throws IOException { HttpURLConnection connection = (HttpURLConnection) request.getUri().toURL().openConnection(); connection.setRequestMethod(request.getMethod()); return connection; }
protected HttpURLConnection createConnection(ClientInvocation request) throws IOException { HttpURLConnection connection = (HttpURLConnection) request.getUri().toURL().openConnection(); connection.setRequestMethod(request.getMethod()); return connection; }
private Request createRequest(ClientInvocation request) { Request.Builder builder = new Request.Builder() .method(request.getMethod(), createRequestBody(request)) .url(request.getUri().toString()); for (Map.Entry<String, List<String>> header : request.getHeaders().asMap().entrySet()) { String headerName = header.getKey(); for (String headerValue : header.getValue()) { builder.addHeader(headerName, headerValue); } } return builder.build(); }
protected void executeRequest(ClientInvocation request, HttpURLConnection connection) { connection.setInstanceFollowRedirects(request.getMethod().equals("GET")); if (request.getEntity() != null) { if (request.getMethod().equals("GET")) { throw new ProcessingException(Messages.MESSAGES.getRequestCannotHaveBody()); } ByteArrayOutputStream baos = new ByteArrayOutputStream(); request.getDelegatingOutputStream().setDelegate(baos); try { request.writeRequestBody(request.getEntityStream()); baos.close(); this.commitHeaders(request, connection); connection.setDoOutput(true); OutputStream e = connection.getOutputStream(); e.write(baos.toByteArray()); e.flush(); e.close(); } catch (IOException ex) { throw new RuntimeException(ex); } } else { this.commitHeaders(request, connection); } }
protected void executeRequest(ClientInvocation request, HttpURLConnection connection) { connection.setInstanceFollowRedirects(request.getMethod().equals("GET")); if (request.getEntity() != null) { if (request.getMethod().equals("GET")) { throw new ProcessingException(Messages.MESSAGES.getRequestCannotHaveBody()); } ByteArrayOutputStream baos = new ByteArrayOutputStream(); request.getDelegatingOutputStream().setDelegate(baos); try { request.writeRequestBody(request.getEntityStream()); baos.close(); this.commitHeaders(request, connection); connection.setDoOutput(true); OutputStream e = connection.getOutputStream(); e.write(baos.toByteArray()); e.flush(); e.close(); } catch (IOException ex) { throw new RuntimeException(ex); } } else { this.commitHeaders(request, connection); } }
private static HttpUriRequest buildHttpRequest(ClientInvocation request) { // Writers may change headers. Thus buffer the content before committing the headers. // For simplicity's sake the content is buffered in memory. File-buffering (ZeroCopyConsumer...) would be // possible, but resource management is error-prone. HttpRequestBase httpRequest = createHttpMethod(request.getUri(), request.getMethod()); if (request.getEntity() != null) { byte[] requestContent = requestContent(request); ByteArrayEntity entity = new ByteArrayEntity(requestContent); entity.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, request.getHeaders().getMediaType().toString())); commitHeaders(request, httpRequest); ((HttpEntityEnclosingRequest) httpRequest).setEntity(entity); } else { commitHeaders(request, httpRequest); } return httpRequest; }
private static HttpUriRequest buildHttpRequest(ClientInvocation request) { // Writers may change headers. Thus buffer the content before committing the headers. // For simplicity's sake the content is buffered in memory. File-buffering (ZeroCopyConsumer...) would be // possible, but resource management is error-prone. HttpRequestBase httpRequest = createHttpMethod(request.getUri(), request.getMethod()); if (request.getEntity() != null) { byte[] requestContent = requestContent(request); ByteArrayEntity entity = new ByteArrayEntity(requestContent); entity.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, request.getHeaders().getMediaType().toString())); commitHeaders(request, httpRequest); ((HttpEntityEnclosingRequest) httpRequest).setEntity(entity); } else { commitHeaders(request, httpRequest); } return httpRequest; }
public ClientResponse invoke(ClientInvocation request) final HttpRequestBase httpMethod = createHttpMethod(uri, request.getMethod()); final HttpResponse res; try