hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: HttpParams appear to be static/global
Date Wed, 24 Aug 2011 14:39:12 GMT
On Wed, 2011-08-24 at 10:28 -0400, Bill Speirs wrote:
> I'm working on a proxy server using the 4.2-alpha1 httpcore and 4.1.2
> httpclient. In the server portion of my code I setup
> SyncBasicHttpParams as follows:
> 
> 
>         HttpParams params = new SyncBasicHttpParams();
> 
>         params.setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 0)
>               .setIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE,
> 8 * 1024)
>               .setBooleanParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK,
> false)
>               .setBooleanParameter(CoreConnectionPNames.TCP_NODELAY, true)
>               .setParameter(CoreProtocolPNames.ORIGIN_SERVER, "FactSet
> Lima Proxy")
>               .setParameter(CoreProtocolPNames.PROTOCOL_VERSION,
> HttpVersion.HTTP_1_1.toString())
>               .setParameter(CoreProtocolPNames.HTTP_ELEMENT_CHARSET,
> HTTP.UTF_8);
> 
> I then use them to create an AsyncNHttpServiceHandler and
> DefaultServerIOEventDispatch.
> 
> In another portion of code I create a new SyncBasicHttpParams object
> and use it to configure my client:
> 		final HttpParams params = new SyncBasicHttpParams();
> 
> 		params.setBooleanParameter(ClientPNames.HANDLE_REDIRECTS, handleRedirects);
> 		params.setBooleanParameter(ClientPNames.ALLOW_CIRCULAR_REDIRECTS, false);
> 		params.setParameter(ClientPNames.COOKIE_POLICY, CookiePolicy.IGNORE_COOKIES);
> 		
> 		HttpConnectionParams.setSoTimeout(params, maxTimeout);
> 		HttpConnectionParams.setConnectionTimeout(params, maxTimeout);
> 		
> 		this.client = new DefaultHttpClient(this.connManager, params);
> 
> However, for some reason the HTTP_ELEMENT_CHARSET parameter is
> "bleeding" over from my server into my client, forcing my client
> requests to be in UTF-8 as well.
> 
> Why is this happening? Are the settings for SyncBasicHttpParams global somehow?
> 

No should be no global settings anywhere in HttpCore or HttpClient.
Please note, though, that parameters set on the HTTP request level will
always take precedence over parameters set on the HTTP client level. I
suspect that parameters of individual messages received by the async
listener inherit its settings.

By the way, since you are using a non-blocking listener for incoming
connections, would not HttpAsyncClient be a better match for handling
outgoing connections than HttpClient?

Cheers

Oleg   



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Mime
View raw message