hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: Can not set Proxy-Connection header
Date Wed, 24 Aug 2005 11:08:11 GMT
On Wed, Aug 24, 2005 at 11:49:00AM +0300, Pesonen, Petteri wrote:
> Hi,
> 
> We are having some proxy problems in our environment and I need to solve
> them by adding a "Proxy-Connection: close" header to the HTTP GET requests,
> but for some reason HttpClient (2.0.2) refuses to do that. Below is an
> example failure from my logs. I first try to remove the header to be sure
> and then to add it with the "close" value. However, looking at the wire log,
> you can notice that HttpClient changed the header value to "keep-alive",
> which is exactly what I don't want. Below is the log snippet and the code
> behind it. Thanks for any help.
> 

Petteri,

Consider overriding the HttpMethodBase#addProxyConnectionHeader with
something of that sort

protected void addProxyConnectionHeader(HttpState state,
                                            HttpConnection conn)
    throws IOException, HttpException {
        LOG.trace("enter HttpMethodBase.addProxyConnectionHeader("
                  + "HttpState, HttpConnection)");
        if (!conn.isTransparent()) {
            setRequestHeader("Proxy-Connection", "Close");
        }
    }

Hope this helps

Oleg

> ...
> DEBUG integration.uriqa.URIQAClient - Proxy-Connection header removed.
> DEBUG integration.uriqa.URIQAClient - Proxy-Connection header set to:
> Proxy-Connection: close
> 
> INFO integration.uriqa.URIQAClient - Calling SNS with query:
> uri=http%3A%2F%2Fforumswd.nokia.com%3A9090%2Fid%2Fvesa_test6&a
> mp;method=MGET ...
> DEBUG httpclient.wire.header - >> "GET
> http://forumsnsd.nokia.com:9090/uriqa/?uri=http%3A%2F%2Fforumswd.nokia.com%3
> A9090%2Fi
> d%2Fvesa_test6&amp;method=MGET HTTP/1.1[\r][\n]"
> DEBUG httpclient.wire.header - >> "Connection: close[\r][\n]"
> DEBUG httpclient.wire.header - >> "User-Agent: Jakarta
> Commons-HttpClient/2.0.2[\r][\n]"
> DEBUG httpclient.wire.header - >> "Host: forumsnsd.nokia.com:9090[\r][\n]"
> DEBUG httpclient.wire.header - >> "Cookie: $Version=0;
> S_ID=CC959CF567784A000294FE70; $Path=/[\r][\n]"
> DEBUG httpclient.wire.header - >> "Proxy-Connection: Keep-Alive[\r][\n]"
> DEBUG httpclient.wire.header - >> "[\r][\n]"
> INFO commons.httpclient.HttpMethodBase - Recoverable exception caught when
> processing request
> WARN commons.httpclient.HttpMethodBase - Recoverable exception caught but
> MethodRetryHandler.retryMethod() returned false, r
> ethrowing exception
> ERROR integration.uriqa.URIQAClient - HttpException in httpclient.
> org.apache.commons.httpclient.HttpRecoverableException:
> java.net.SocketException: Connection reset by peer: Connection reset
>  by peer
>         at
> org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBase.jav
> a:1962)
>         at
> org.apache.commons.httpclient.HttpMethodBase.processRequest(HttpMethodBase.j
> ava:2653)                            
>         at
> org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:108
> 7)
>         at
> org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:643)
>         at
> org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:497)
>         at
> com.forum.nokia.downloadportal.integration.uriqa.URIQAClient.mget(URIQAClien
> t.java:117)
>         at
> com.forum.nokia.downloadportal.model.Download.getMetadata(Download.java:177)
>         at
> com.forum.nokia.downloadportal.model.Download.doAction(Download.java:187)
> 
>         at
> com.forum.nokia.downloadportal.model.ActionHandler.doDownload(ActionHandler.
> java:55)                             
>         at
> com.forum.nokia.downloadportal.webapp.Download.service(Download.java:198)
> 
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> 
>         at
> weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
> :262)                                
>         at
> weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
> :198)                                
>         at
> weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletCo
> ntext.java:2678)                     
>         at
> weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java
> :2412)                               
>         at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:140)
> 
>         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:121)   
> ...
> 
> The code that generated all this is below:
> ...
> method.removeRequestHeader("Connection");
> logger.debug("Connection header removed.");
> method.addRequestHeader("Connection", "close");
> logger.debug("Connection header set to: " +
> method.getRequestHeader("Connection") );
> method.removeRequestHeader("Proxy-Connection");
> logger.debug("Proxy-Connection header removed.");
> method.addRequestHeader("Proxy-Connection", "close");
> logger.debug("Proxy-Connection header set to: " +
> method.getRequestHeader("Proxy-Connection") );
> Metadata metadata;
>  try {
>  	// Execute the mget method.
>   	logger.info("Calling SNS with query:  " + method.getQueryString() +
> " ...");
>   	int statusCode = URIQAClient.client.executeMethod( method );
> ...
> 
> 
> 
> -- 
> Petteri  :: +358-40-8619334
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org


Mime
View raw message