@Override public String toString() { return "ClientResponse{" + "method=" + requestContext.getMethod() + ", uri=" + requestContext.getUri() + ", status=" + status.getStatusCode() + ", reason=" + status.getReasonPhrase() + "}"; }
@Override public String toString() { return "ClientResponse{" + "method=" + requestContext.getMethod() + ", uri=" + requestContext.getUri() + ", status=" + status.getStatusCode() + ", reason=" + status.getReasonPhrase() + "}"; }
private HttpRequest createHttpRequest(ClientRequest request) { Object entity = request.getEntity(); if (entity == null) { return HttpRequest.createBodyless(request.getMethod(), request.getUri()); } RequestEntityProcessing entityProcessing = request.resolveProperty( ClientProperties.REQUEST_ENTITY_PROCESSING, RequestEntityProcessing.class); HttpRequest httpRequest; if (entityProcessing != null && entityProcessing == RequestEntityProcessing.CHUNKED) { httpRequest = HttpRequest.createChunked(request.getMethod(), request.getUri(), connectorConfiguration.getChunkSize()); } else { httpRequest = HttpRequest.createBuffered(request.getMethod(), request.getUri()); } return httpRequest; }
@Override public String toString() { return "ClientResponse{" + "method=" + requestContext.getMethod() + ", uri=" + requestContext.getUri() + ", status=" + status.getStatusCode() + ", reason=" + status.getReasonPhrase() + "}"; }
private void validateHttpMethodAndEntity(final ClientRequest request) { boolean suppressExceptions; suppressExceptions = PropertiesHelper.isProperty( request.getConfiguration().getProperty(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION)); final Object shcvProperty = request.getProperty(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION); if (shcvProperty != null) { // override global configuration with request-specific suppressExceptions = PropertiesHelper.isProperty(shcvProperty); } final String method = request.getMethod(); final EntityPresence entityPresence = METHODS.get(method.toUpperCase()); if (entityPresence == EntityPresence.MUST_BE_NULL && request.hasEntity()) { if (suppressExceptions) { LOGGER.warning(LocalizationMessages.ERROR_HTTP_METHOD_ENTITY_NOT_NULL(method)); } else { throw new IllegalStateException(LocalizationMessages.ERROR_HTTP_METHOD_ENTITY_NOT_NULL(method)); } } else if (entityPresence == EntityPresence.MUST_BE_PRESENT && !request.hasEntity()) { if (suppressExceptions) { LOGGER.warning(LocalizationMessages.ERROR_HTTP_METHOD_ENTITY_NULL(method)); } else { throw new IllegalStateException(LocalizationMessages.ERROR_HTTP_METHOD_ENTITY_NULL(method)); } } }
private void validateHttpMethodAndEntity(final ClientRequest request) { boolean suppressExceptions; suppressExceptions = PropertiesHelper.isProperty( request.getConfiguration().getProperty(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION)); final Object shcvProperty = request.getProperty(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION); if (shcvProperty != null) { // override global configuration with request-specific suppressExceptions = PropertiesHelper.isProperty(shcvProperty); } final String method = request.getMethod(); final EntityPresence entityPresence = METHODS.get(method.toUpperCase()); if (entityPresence == EntityPresence.MUST_BE_NULL && request.hasEntity()) { if (suppressExceptions) { LOGGER.warning(LocalizationMessages.ERROR_HTTP_METHOD_ENTITY_NOT_NULL(method)); } else { throw new IllegalStateException(LocalizationMessages.ERROR_HTTP_METHOD_ENTITY_NOT_NULL(method)); } } else if (entityPresence == EntityPresence.MUST_BE_PRESENT && !request.hasEntity()) { if (suppressExceptions) { LOGGER.warning(LocalizationMessages.ERROR_HTTP_METHOD_ENTITY_NULL(method)); } else { throw new IllegalStateException(LocalizationMessages.ERROR_HTTP_METHOD_ENTITY_NULL(method)); } } }
private Request translateRequest(final ClientRequest clientRequest) { final URI uri = clientRequest.getUri(); final Request request = client.newRequest(uri); request.method(clientRequest.getMethod()); 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; }
uc.setDoInput(true); final String httpMethod = request.getMethod(); if (request.resolveProperty(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND, setMethodWorkaround)) { setRequestMethodViaJreBugWorkaround(uc, httpMethod);
uc.setDoInput(true); final String httpMethod = request.getMethod(); if (request.resolveProperty(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND, setMethodWorkaround)) { setRequestMethodViaJreBugWorkaround(uc, httpMethod);
private void validateHttpMethodAndEntity(final ClientRequest request) { boolean suppressExceptions; suppressExceptions = PropertiesHelper.isProperty( request.getConfiguration().getProperty(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION)); final Object shcvProperty = request.getProperty(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION); if (shcvProperty != null) { // override global configuration with request-specific suppressExceptions = PropertiesHelper.isProperty(shcvProperty); } final String method = request.getMethod(); final EntityPresence entityPresence = METHODS.get(method.toUpperCase()); if (entityPresence == EntityPresence.MUST_BE_NULL && request.hasEntity()) { if (suppressExceptions) { LOGGER.warning(LocalizationMessages.ERROR_HTTP_METHOD_ENTITY_NOT_NULL(method)); } else { throw new IllegalStateException(LocalizationMessages.ERROR_HTTP_METHOD_ENTITY_NOT_NULL(method)); } } else if (entityPresence == EntityPresence.MUST_BE_PRESENT && !request.hasEntity()) { if (suppressExceptions) { LOGGER.warning(LocalizationMessages.ERROR_HTTP_METHOD_ENTITY_NULL(method)); } else { throw new IllegalStateException(LocalizationMessages.ERROR_HTTP_METHOD_ENTITY_NULL(method)); } } }
/** * Build a new Apache's {@link org.apache.http.client.methods.HttpUriRequest} * from Jersey's {@link org.glassfish.jersey.client.ClientRequest} * <p> * Convert a method, URI, body, headers and override a user-agent if necessary * </p> * * @param jerseyRequest representation of an HTTP request in Jersey * @return a new {@link org.apache.http.client.methods.HttpUriRequest} */ private HttpUriRequest buildApacheRequest(ClientRequest jerseyRequest) { final RequestBuilder builder = RequestBuilder .create(jerseyRequest.getMethod()) .setUri(jerseyRequest.getUri()) .setEntity(getHttpEntity(jerseyRequest)); for (String headerName : jerseyRequest.getHeaders().keySet()) { builder.addHeader(headerName, jerseyRequest.getHeaderString(headerName)); } final Optional<RequestConfig> requestConfig = addJerseyRequestConfig(jerseyRequest); requestConfig.ifPresent(builder::setConfig); return builder.build(); }
uc.setDoInput(true); final String httpMethod = request.getMethod(); if (request.resolveProperty(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND, setMethodWorkaround)) { setRequestMethodViaJreBugWorkaround(uc, httpMethod);
private HttpUriRequest getUriHttpRequest(final ClientRequest clientRequest) { final RequestConfig.Builder requestConfigBuilder = RequestConfig.copy(requestConfig); final int connectTimeout = clientRequest.resolveProperty(ClientProperties.CONNECT_TIMEOUT, -1); final int socketTimeout = clientRequest.resolveProperty(ClientProperties.READ_TIMEOUT, -1); if (connectTimeout >= 0) { requestConfigBuilder.setConnectTimeout(connectTimeout); } if (socketTimeout >= 0) { requestConfigBuilder.setSocketTimeout(socketTimeout); } final Boolean redirectsEnabled = clientRequest.resolveProperty(ClientProperties.FOLLOW_REDIRECTS, requestConfig.isRedirectsEnabled()); requestConfigBuilder.setRedirectsEnabled(redirectsEnabled); final Boolean bufferingEnabled = clientRequest.resolveProperty(ClientProperties.REQUEST_ENTITY_PROCESSING, RequestEntityProcessing.class) == RequestEntityProcessing.BUFFERED; final HttpEntity entity = getHttpEntity(clientRequest, bufferingEnabled); return RequestBuilder .create(clientRequest.getMethod()) .setUri(clientRequest.getUri()) .setConfig(requestConfigBuilder.build()) .setEntity(entity) .build(); }
clientRequest.getUri(), clientRequest.getMethod(), null, propertiesDelegate);
private com.ning.http.client.Request translate(final ClientRequest requestContext) { final String strMethod = requestContext.getMethod(); final URI uri = requestContext.getUri();
private Request translateRequest(final ClientRequest clientRequest) { final URI uri = clientRequest.getUri(); final Request request = client.newRequest(uri); request.method(clientRequest.getMethod()); 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; }
private HttpUriRequest toUriHttpRequest(final ClientRequest request) { final HttpEntity entity = this.getHttpEntity(request); return RequestBuilder .create(request.getMethod()) .setUri(request.getUri()) .setEntity(entity) .build(); }
@Override public String toString() { return MoreObjects .toStringHelper(this) .add("method", requestContext.getMethod()) .add("uri", requestContext.getUri()) .add("status", status.getStatusCode()) .add("reason", status.getReasonPhrase()) .toString(); }
@Override public String toString() { return MoreObjects .toStringHelper(this) .add("method", requestContext.getMethod()) .add("uri", requestContext.getUri()) .add("status", status.getStatusCode()) .add("reason", status.getReasonPhrase()) .toString(); }