/** * Enable a buffering of serialized entity. The buffering will be configured from runtime configuration * associated with this request. The property determining the size of the buffer * is {@link org.glassfish.jersey.CommonProperties#OUTBOUND_CONTENT_LENGTH_BUFFER}. * <p/> * The buffering functionality is by default disabled and could be enabled by calling this method. In this case * this method must be called before first bytes are written to the {@link #getEntityStream() entity stream}. * */ public void enableBuffering() { enableBuffering(getConfiguration()); }
/** * Enable a buffering of serialized entity. The buffering will be configured from runtime configuration * associated with this request. The property determining the size of the buffer * is {@link org.glassfish.jersey.CommonProperties#OUTBOUND_CONTENT_LENGTH_BUFFER}. * <p/> * The buffering functionality is by default disabled and could be enabled by calling this method. In this case * this method must be called before first bytes are written to the {@link #getEntityStream() entity stream}. * */ public void enableBuffering() { enableBuffering(getConfiguration()); }
/** * Enable a buffering of serialized entity. The buffering will be configured from runtime configuration * associated with this request. The property determining the size of the buffer * is {@link org.glassfish.jersey.CommonProperties#OUTBOUND_CONTENT_LENGTH_BUFFER}. * <p/> * The buffering functionality is by default disabled and could be enabled by calling this method. In this case * this method must be called before first bytes are written to the {@link #getEntityStream() entity stream}. * */ public void enableBuffering() { enableBuffering(getConfiguration()); }
Integer timeout = ClientProperties.getValue(jerseyRequest.getConfiguration().getProperties(), ClientProperties.READ_TIMEOUT, 0);
@Override protected void initChannel(SocketChannel ch) throws Exception { ChannelPipeline p = ch.pipeline(); // Enable HTTPS if necessary. if ("https".equals(requestUri.getScheme())) { // making client authentication optional for now; it could be extracted to configurable property JdkSslContext jdkSslContext = new JdkSslContext(client.getSslContext(), true, ClientAuth.NONE); p.addLast(jdkSslContext.newHandler(ch.alloc())); } // http proxy Configuration config = jerseyRequest.getConfiguration(); final Object proxyUri = config.getProperties().get(ClientProperties.PROXY_URI); if (proxyUri != null) { final URI u = getProxyUri(proxyUri); final String userName = ClientProperties.getValue( config.getProperties(), ClientProperties.PROXY_USERNAME, String.class); final String password = ClientProperties.getValue( config.getProperties(), ClientProperties.PROXY_PASSWORD, String.class); p.addLast(new HttpProxyHandler(new InetSocketAddress(u.getHost(), u.getPort() == -1 ? 8080 : u.getPort()), userName, password)); } p.addLast(new HttpClientCodec()); p.addLast(new ChunkedWriteHandler()); p.addLast(new HttpContentDecompressor()); p.addLast(new JerseyClientHandler(NettyConnector.this, jerseyRequest, jerseyCallback, settableFuture)); } });
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)); } } }
Integer connectTimeout = ClientProperties.getValue(jerseyRequest.getConfiguration().getProperties(), ClientProperties.CONNECT_TIMEOUT, 0); if (connectTimeout > 0) {
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 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)); } } }
boolean followRedirects = ClientProperties.getValue(clientRequest.getConfiguration().getProperties(), ClientProperties.FOLLOW_REDIRECTS, true);
/** * Enable a buffering of serialized entity. The buffering will be configured from runtime configuration * associated with this request. The property determining the size of the buffer * is {@link org.glassfish.jersey.CommonProperties#OUTBOUND_CONTENT_LENGTH_BUFFER}. * <p/> * The buffering functionality is by default disabled and could be enabled by calling this method. In this case * this method must be called before first bytes are written to the {@link #getEntityStream() entity stream}. * */ public void enableBuffering() { enableBuffering(getConfiguration()); }
/** * Enable a buffering of serialized entity. The buffering will be configured from runtime configuration * associated with this request. The property determining the size of the buffer * is {@link org.glassfish.jersey.CommonProperties#OUTBOUND_CONTENT_LENGTH_BUFFER}. * <p/> * The buffering functionality is by default disabled and could be enabled by calling this method. In this case * this method must be called before first bytes are written to the {@link #getEntityStream() entity stream}. * */ public void enableBuffering() { enableBuffering(getConfiguration()); }
/** * Enable a buffering of serialized entity. The buffering will be configured from runtime configuration * associated with this request. The property determining the size of the buffer * is {@link org.glassfish.jersey.CommonProperties#OUTBOUND_CONTENT_LENGTH_BUFFER}. * <p/> * The buffering functionality is by default disabled and could be enabled by calling this method. In this case * this method must be called before first bytes are written to the {@link #getEntityStream() entity stream}. * */ public void enableBuffering() { enableBuffering(getConfiguration()); }
/** * Enable a buffering of serialized entity. The buffering will be configured from runtime configuration * associated with this request. The property determining the size of the buffer * is {@link org.glassfish.jersey.CommonProperties#OUTBOUND_CONTENT_LENGTH_BUFFER}. * <p/> * The buffering functionality is by default disabled and could be enabled by calling this method. In this case * this method must be called before first bytes are written to the {@link #getEntityStream() entity stream}. * */ public void enableBuffering() { enableBuffering(getConfiguration()); }
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 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; }