dev@glassfish.java.net

Re: Duplicate http headers

From: Ashish Sahni <Ashish.Sahni_at_Sun.COM>
Date: Thu, 01 Feb 2007 11:26:24 -0800

I just has a look at the cgi functionality in glassfish and
it seems to be parsing the input from the exec'ed process to set the
corresponding
status/headers in the http-servlet-response. Looks like no easy solution
exists and
I might have to do something similar. Any thoughts ?

Thanks
Ashish

Ashish Sahni wrote:

> Hi Jan,
>
> The code that generating the http response(headers + content) does not
> have a handle to the HttpServletResponse object. It only has a
> reference to
> the OutputStream.
> How about this theory on what's happening - when no headers/status is
> committed via the response object, the web container takes it upon itself
> to set the headers once it sees the data on the outputstream -
> right/wrong ?
> Can it(webcontainer-setting-http-response-headers) be suppressed ?
>
> Thanks
> Ashish
>
> Jan Luehe wrote:
>
>> Hi Ashish,
>>
>> Ashish Sahni wrote On 01/31/07 06:18 PM,:
>>
>>> Hi Jeanfrancois,
>>>
>>> Actually this is as a regular webapp ie, within GlassFish web
>>> container not standalone grizzly.
>>
>>
>>
>>
>> If you are referring to
>>
>> https://glassfish.dev.java.net/issues/show_bug.cgi?id=2261
>> ("response.setHeader is erroneously behaving like response.addHeader")
>>
>> this has long been fixed ...
>>
>>
>> Jan
>>
>>>
>>> -Ashish
>>>
>>> Jeanfrancois Arcand wrote:
>>>
>>>> Hi Ashish,
>>>>
>>>> Ashish Sahni wrote:
>>>>
>>>>> Hi,
>>>>> I have a web application that passes the
>>>>> httpservletresponse(outputstream actually)
>>>>> to an external lib/code that I don't have control over.
>>>>> The application seems to be working correctly other than the fact
>>>>> that the http headers
>>>>> are duplicated in the response(see below).
>>>>> I remember seeing a discussion on http-header-duplication but
>>>>> can't seem to find it
>>>>> and nothing seems to jump out in API docs.
>>>>>
>>>>> How do I prevent the webcontainer from 'committing' the http
>>>>> response headers ?
>>>>
>>>>
>>>>
>>>>
>>>> This happens with Grizzly standalone, right? Not with the normal
>>>> Grizzly/GlassFish HTTP port. You need to do something like:
>>>>
>>>> ((c.s.e.w.connector.grizzly.SocketChannelOutputBuffer)org.apache.coyote.Response.getOutputBuffer()).commit();
>>>>
>>>>
>>>> before writing bytes using the SocketChannel. This will discard the
>>>> Grizzly HTTP header, and then you will be able to add yours. You
>>>> can find the complete Rails example here:
>>>>
>>>> http://fisheye5.cenqua.com/browse/glassfish/appserv-http-engine/modules/rails/src/main/java/com/sun/grizzly/rails/RailsAdapter.java?r=1.6
>>>>
>>>>
>>>> Thanks
>>>>
>>>> -- Jeanfrancois
>>>>
>>>>
>>>>
>>>>
>>>>>
>>>>> Thanks
>>>>> Ashish
>>>>>
>>>>>
>>>>> HTTP/1.x 200 OK
>>>>> X-powered-by: Servlet/2.5
>>>>> Content-Type: text/plain; charset=iso-8859-1
>>>>> Transfer-Encoding: chunked
>>>>> Date: Wed, 31 Jan 2007 23:52:02 GMT
>>>>>
>>>>> HTTP/1.1 200 OK
>>>>> Date: Wed, 31 Jan 2007 23:52:02 GMT
>>>>> Content-Type: text/html
>>>>> Set-Cookie: _session_id=253bb5948d11ecf0671e4af2bb9b2cee; path=/
>>>>> Status: 200 OK
>>>>> Cache-Control: no-cache
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
>>>>> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
>>>> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>>>>
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
>> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>