Roland, Ofcourse this is not an HttpClient problem! It works impeccably for me and the developers have done a great job on that one!!!
Sorry for quoting my issue out of context, but yeah it is a standalone proxy "like" application. Yes, you are right that I should read the RFC carefully again. Even I was thinking the same that the headers may look a little different for proxies. Thanks a bunch again. Regards Vish ------------------------------------------------------------------------------------------------------------------------------------------------------------------- SOMETIMES YOU NEED TO GO FAR, TO FIND WHAT IS CLOSEST TO YOU -----Original Message----- From: Roland Weber [mailto:[EMAIL PROTECTED] Sent: Monday, May 09, 2005 10:18 AM To: HttpClient User Discussion Subject: Re: Wierd results when writing response headers to browser Hello Vish, first of all, this does not sound like an HttpClient problem. Second, you are very unspecific about what you actually do. What does "HttpClient" mean in your sequence diagramm? Is it a standalone program that uses HttpClient to act as a proxy? Or is it a servlet (in which case you cannot send back headers by writing them to the response body)? If it's a servlet, have a look at the Servlet API to see how headers can be sent back to the client. If it's a standalone program, check whether any content-length fields match the size of the data you are writing. Make sure that you apply the encodings listed in the transfer-encoding header. In general, it is not as easy as it may sound to implement an HTTP proxy. You should study the RFC about HTTP/1.1 *very* carefully. Search for every occurrence of "proxy" there. And check out which of the headers are valid only for a single hop rather than the end-to-end communication. hope that helps, Roland "Sambaiah, Vishwas" <[EMAIL PROTECTED]> 09.05.2005 15:38 Please respond to "HttpClient User Discussion" To "HttpClient User Discussion" <[email protected]> cc Subject Wierd results when writing response headers to browser Hi, Sorry to be posting this again but I am in dire need of some suggestions. In a simple request-response sequel between the browser --> HttpClient --> Host, I read the response headers (prepend it with StatusLine), the response body as bytes and write it back to the browser (which originated the requests) in that order. I have ensures per RFC that CRLF follows each response header and an additional one at the end of response headers. I continuously get Connection Reset By Peer exception if I write the response to the browser. If I dont write the response headers, everything works just fine except that there are some websites I cannot access which set cookies/ create URLs using Javascripts. I guess I have hit a dead end thinking on this....Thoughts? Suggestions? Appreciate your time in advance. -------------------- here 'client' is a class where I instantiate HttpClient, 'out' is browser socket String responseHeaders = client.getResponseHeaders(); (This is parsed string) if(responseHeaders != null) out.write(responseHeaders.getBytes()); System.out.println("CUSTOM LOG :: Response Headers = " + responseHeaders); byte data[] = new byte[2000]; int count; while (( count = in.read(data)) > 0) { // Send bytesto client out.write(data,0,count); } System.out.println("CUSTOM LOG :: Response Body = " + responseBody); } String responseFooters = client.getResponseFooters(); if(responseFooters != null) out.write(responseFooters.getBytes()); System.out.println("CUSTOM LOG :: Response Footers = " + responseFooters); ------------------ Much Thanks, Vish ------------------------------------------------------------------------------------------------------------------------------------------------------------------- SOMETIMES YOU NEED TO GO FAR, TO FIND WHAT IS CLOSEST TO YOU -----Original Message----- From: Vishwas [mailto:[EMAIL PROTECTED] Sent: Sunday, May 08, 2005 11:31 AM To: [email protected] Subject: Wierd results when writing response headers to browser Hi, In a simple request-response sequel between the browser --> HttpClient --> Host, I read the response headers (prepend it with StatusLine), the response body as bytes and write it back to the browser (which originated the requests) in that order. I have ensures per RFC that CRLF follows each response header and an additional one at the end of response headers. I continuously get Connection Reset By Peer exception if I write the response to the browser. If I dont write the response headers, everything works just fine except that there are some websites I cannot access which set cookies/ create URLs using Javascripts. I guess I have hit a dead end thinking on this....Thoughts? Suggestions? Appreciate your time in advance. -------------------- here 'client' is a class where I instantiate HttpClient, 'out' is browser socket String responseHeaders = client.getResponseHeaders(); (This is parsed string) if(responseHeaders != null) out.write(responseHeaders.getBytes()); System.out.println("CUSTOM LOG :: Response Headers = " + responseHeaders); byte data[] = new byte[2000]; int count; while (( count = in.read(data)) > 0) { // Send bytesto client out.write(data,0,count); } System.out.println("CUSTOM LOG :: Response Body = " + responseBody); } String responseFooters = client.getResponseFooters(); if(responseFooters != null) out.write(responseFooters.getBytes()); System.out.println("CUSTOM LOG :: Response Footers = " + responseFooters); ------------------ Much Thanks, Vish --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
