public RestEasyClientInProcRequest(ClientRequest clientRequest) { this.clientRequest = clientRequest; try { headers.put("Host", UrlHelper.getRequestHost(new URI(clientRequest.getUri()))); } catch (Exception e) { throw new RuntimeException(e); } if (clientRequest.getBodyContentType() != null) { headers.put("Content-type", clientRequest.getBodyContentType().toString()); } headers.putAll(asMap(clientRequest.getHeaders())); }
public RestEasyClientInProcRequest(ClientRequest clientRequest) { this.clientRequest = clientRequest; try { headers.put("Host", UrlHelper.getRequestHost(new URI(clientRequest.getUri()))); } catch (Exception e) { throw new RuntimeException(e); } if (clientRequest.getBodyContentType() != null) { headers.put("Content-type", clientRequest.getBodyContentType().toString()); } headers.putAll(asMap(clientRequest.getHeaders())); }
/** * Build the HttpEntity to be sent to the Service as part of (POST) request. Creates a off-memory * {@link FileExposingFileEntity} or a regular in-memory {@link ByteArrayEntity} depending on if the request * OutputStream fit into memory when built by calling {@link #writeRequestBodyToOutputStream(ClientRequest)}. * * @param request - * @return - the built HttpEntity * @throws IOException - */ protected HttpEntity buildEntity(final ClientRequest request) throws IOException { HttpEntity entityToBuild = null; DeferredFileOutputStream memoryManagedOutStream = writeRequestBodyToOutputStream(request); if (memoryManagedOutStream.isInMemory()) { ByteArrayEntity entityToBuildByteArray = new ByteArrayEntity(memoryManagedOutStream.getData()); entityToBuildByteArray.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, request.getBodyContentType().toString())); entityToBuild = entityToBuildByteArray; } else { entityToBuild = new FileExposingFileEntity(memoryManagedOutStream.getFile(), request.getBodyContentType().toString()); } return entityToBuild; }
/** * Build the HttpEntity to be sent to the Service as part of (POST) request. Creates a off-memory * {@link FileExposingFileEntity} or a regular in-memory {@link ByteArrayEntity} depending on if the request * OutputStream fit into memory when built by calling {@link #writeRequestBodyToOutputStream(ClientRequest)}. * * @param request - * @return - the built HttpEntity * @throws IOException - */ protected HttpEntity buildEntity(final ClientRequest request) throws IOException { HttpEntity entityToBuild = null; DeferredFileOutputStream memoryManagedOutStream = writeRequestBodyToOutputStream(request); if (memoryManagedOutStream.isInMemory()) { ByteArrayEntity entityToBuildByteArray = new ByteArrayEntity(memoryManagedOutStream.getData()); entityToBuildByteArray.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, request.getBodyContentType().toString())); entityToBuild = entityToBuildByteArray; } else { entityToBuild = new FileExposingFileEntity(memoryManagedOutStream.getFile(), request.getBodyContentType().toString()); } return entityToBuild; }
String type = request.getBodyContentType().toString(); connection.addRequestProperty(CONTENT_TYPE, type);
String type = request.getBodyContentType().toString(); connection.addRequestProperty(CONTENT_TYPE, type);
MediaType bodyContentType = request.getBodyContentType(); request.getHeadersAsObjects().add(HttpHeaders.CONTENT_TYPE, bodyContentType.toString());
MediaType bodyContentType = request.getBodyContentType(); request.getHeadersAsObjects().add(HttpHeaders.CONTENT_TYPE, bodyContentType.toString());