Oleg,
That would explain my chunked data problem. I will exclude all
hop-by-hop headers from being transfered.
Thanks,
Warren Bell
On 2/9/12 6:11 AM, Oleg Kalnichevski wrote:
> On Wed, 2012-02-08 at 19:10 -0800, Warren Bell wrote:
>> I am writing a small proxy servlet and want to know what is the best way
>> to convert the entity from an org.apache.http.HttpResponse, I am getting
>> from a destination server through HttpClient, into the
>> javax.servlet.http.HttpServletResponse outputStream I need in my servlet
>> to send back to the client's browser. I am currently doing something
>> like this below, but I am running into issues with chunked data.
>>
>> I have already transferred all response headers from
>> orgApacheHttpHttpResponse to javaxServletHttpHttpServletResponse before
>> the code below.
>>
>> ...
>>
>> HttpEntity entity = orgApacheHttpHttpResponse.getEntity();
>>
>> InputStream inputStream = null;
>> try
>> {
>> inputStream = entity.getContent();
>> BufferedInputStream bufferedInputStream = new
>> BufferedInputStream(inputStream);
>> OutputStream outputStream =
>> javaxServletHttpHttpServletResponse.getOutputStream();
>> int intNextByte;
>> while((intNextByte = bufferedInputStream.read()) != -1)
>> {
>> outputStream.write(intNextByte);
>> }
>> }
>> catch(IOException ioex)
>> {
>> ...
>> }
>> catch(RuntimeException rex)
>> {
>> ...
>> }
>> finally
>> {
>> Close all streams
>> }
>>
>>
>> The code above does work when I manually exclude the "Transfer-Encoding:
>> chunked" header from the javax.servlet.http.HttpServletResponse, but am
>> I suppose to do that ?
>
> Yes, you are. There are so called 'hop-by-hop' headers that MAY NOT be
> transmitted by HTTP proxies to the next hop. See RFC 2616, section
> 13.5.1: 'End-to-end and Hop-by-hop Headers'.
>
> Oleg
>
>
>> Basically the response that comes back to the
>> client's browser should be the same as the response that comes back to
>> HTTPClient in my servlet.
>>
>> Also, are there any response headers that I should not transfer over to
>> javax.servlet.http.HttpServletResponse like maybe Transfer-Encoding ?
>> Are there headers that get added by the web server after my response has
>> left the servlet ?
>>
>>
>
>
>
> ---------------------------------------------------------------------
> 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]