hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexander Müller" <Alexander.Muel...@brz.gv.at>
Subject receiveResponseHeader() halting
Date Wed, 13 May 2009 11:40:10 GMT

Hi,

I am trying to come up with a Reverse Proxy using HttpCore, however came across some difficulties
and hope someone here could point me into the right direction.

Basically I am having a servlet putting all of the received headers into a BasicHttpRequest
instance, which it then sends with sendRequestHeaders(). So far this would work, however once
I try to get the response by receiveResponseHeader() it simply stalls at AbstractSessionInputBuffer.fillBuffer()
upon reading from instream. This would make me believe the server hasnt yet sent any response
- most probably because it didnt yet receive the full request. I could confirm the latter
partly when I tried to send the request manually (via the socket's output stream) as I could
then receive the response successfully. Furthermore it also seems to work by not using sendRequestHeader()
and receiveResponseHeader() but instead a HttpRequestExecutor.

My assumption would be that something about sending the request is not right yet, but I couldnt
say what. Below is an a bit trimmed down version, did I miss something?

            HttpRequest req=null;
            req=new BasicHttpRequest(request.getMethod(), "path-to-connect-to");
            
            for (Enumeration<String> e=request.getHeaderNames(); e.hasMoreElements();
)
            {
                String header=e.nextElement();

                for (Enumeration<String> _e=request.getHeaders(header); _e.hasMoreElements();
)
                    req.addHeader(header, _e.nextElement());
            }
            
            Socket socket=new Socket('hostname', 80);
            
            DefaultHttpClientConnection con=new DefaultHttpClientConnection();
            con.bind(socket, new BasicHttpParams());
            
            con.sendRequestHeader(req);
            
            HttpResponse resp=con.receiveResponseHeader();
            
            response.setStatus(resp.getStatusLine().getStatusCode());


Thanks for any help,
Alexander


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


Mime
View raw message