You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modules-dev@httpd.apache.org by Rui Hu <tc...@gmail.com> on 2012/03/16 04:22:12 UTC

one question about HTTP response header "Content-Length"

hi,

I have a private module which want to get the ultimate value of
"Content-Length" , and I hook this module in fixups. However, result shows
that "Content-Length" is NULL when I get it.

Which process should I hook if I want to get Content-Length's ultimate
value? Any suggestion?

Many thanks!

Vic

-- 
Best regards,

Rui Hu
----------------------------------------------------------------------------------------
State Key Laboratory of Networking & Switching Technology
Beijing University of Posts and Telecommunications(BUPT)
MSN: tchrbupt@gmail.com
-----------------------------------------------------------------------------------------

Re: one question about HTTP response header "Content-Length"

Posted by Joe Lewis <jo...@joe-lewis.com>.
On 3/16/12 12:54 AM, Rui Hu wrote:
> Sorry I didn't describe my question accurately. I want to modify
> "Cache-Control" depending on "Content-Length" and "Content-Type", and
> "Content-Type" depending on r->uri. Therefore I must get those two fields
> and set that one field.
>
> Any suggestion?

An output filter is probably where you want to be.  There are plenty of 
examples from previous posts (search the archives) if you want to know 
how to use one.

Joe
--
http://www.silverhawk.net/


Re: one question about HTTP response header "Content-Length"

Posted by Rui Hu <tc...@gmail.com>.
Sorry I didn't describe my question accurately. I want to modify
"Cache-Control" depending on "Content-Length" and "Content-Type", and
"Content-Type" depending on r->uri. Therefore I must get those two fields
and set that one field.

Any suggestion?

Thanks very much!

VIc

2012/3/16 Joe Lewis <jo...@joe-lewis.com>

> On 3/16/12 12:31 AM, Rui Hu wrote:
>
>> I have another question. I found that not every request's response header
>> has field of "Content-Length", is it normal?
>>
>
> That depends on what "normal" is.  You are probably looking at what the
> content generators have provided, and the generators don't always set that.
>  You might find that cgi's may or may not have the header.  There are other
> modules hooking into things that alter the content even more, e.g. chunking
> and gzipping to name some examples of content being altered, and therefor,
> the headers having to be altered.
>
> If what you want is the served content length header, you might even
> consider hooking in a logging hook that provides the setting.
>
>
>  Additionally, can I modify HTTP response header in output filter of
>> AP_FTYPE_PROTOCOL type?
>>
> Probably.  I would only modify that if you were using an output filter
> (e.g. compression, again).
>
> Joe
> --
> http://www.silverhawk.net/
>



-- 
Best regards,

Rui Hu
----------------------------------------------------------------------------------------
State Key Laboratory of Networking & Switching Technology
Beijing University of Posts and Telecommunications(BUPT)
MSN: tchrbupt@gmail.com
-----------------------------------------------------------------------------------------

Re: one question about HTTP response header "Content-Length"

Posted by Joe Lewis <jo...@joe-lewis.com>.
On 3/16/12 12:31 AM, Rui Hu wrote:
> I have another question. I found that not every request's response header
> has field of "Content-Length", is it normal?

That depends on what "normal" is.  You are probably looking at what the 
content generators have provided, and the generators don't always set 
that.  You might find that cgi's may or may not have the header.  There 
are other modules hooking into things that alter the content even more, 
e.g. chunking and gzipping to name some examples of content being 
altered, and therefor, the headers having to be altered.

If what you want is the served content length header, you might even 
consider hooking in a logging hook that provides the setting.

> Additionally, can I modify HTTP response header in output filter of
> AP_FTYPE_PROTOCOL type?
Probably.  I would only modify that if you were using an output filter 
(e.g. compression, again).

Joe
--
http://www.silverhawk.net/

Re: one question about HTTP response header "Content-Length"

Posted by Rui Hu <tc...@gmail.com>.
I have another question. I found that not every request's response header
has field of "Content-Length", is it normal?

Additionally, can I modify HTTP response header in output filter of
AP_FTYPE_PROTOCOL type?

Many thanks!

Vic


2012/3/16 Joe Lewis <jl...@silverhawk.net>

> Fix UPS runs before other hooks. Output filters run after content
> generation. If you can be the last output filter, you should have that
> value in the headers out table.
>
> Joe
> --
> Http://www.silverhawk.net/
> On Mar 15, 2012 9:22 PM, "Rui Hu" <tc...@gmail.com> wrote:
>
> > hi,
> >
> > I have a private module which want to get the ultimate value of
> > "Content-Length" , and I hook this module in fixups. However, result
> shows
> > that "Content-Length" is NULL when I get it.
> >
> > Which process should I hook if I want to get Content-Length's ultimate
> > value? Any suggestion?
> >
> > Many thanks!
> >
> > Vic
> >
> > --
> > Best regards,
> >
> > Rui Hu
> >
> >
> ----------------------------------------------------------------------------------------
> > State Key Laboratory of Networking & Switching Technology
> > Beijing University of Posts and Telecommunications(BUPT)
> > MSN: tchrbupt@gmail.com
> >
> >
> -----------------------------------------------------------------------------------------
> >
>



-- 
Best regards,

Rui Hu
----------------------------------------------------------------------------------------
State Key Laboratory of Networking & Switching Technology
Beijing University of Posts and Telecommunications(BUPT)
MSN: tchrbupt@gmail.com
-----------------------------------------------------------------------------------------

Re: one question about HTTP response header "Content-Length"

Posted by Joe Lewis <jl...@silverhawk.net>.
Fix UPS runs before other hooks. Output filters run after content
generation. If you can be the last output filter, you should have that
value in the headers out table.

Joe
--
Http://www.silverhawk.net/
On Mar 15, 2012 9:22 PM, "Rui Hu" <tc...@gmail.com> wrote:

> hi,
>
> I have a private module which want to get the ultimate value of
> "Content-Length" , and I hook this module in fixups. However, result shows
> that "Content-Length" is NULL when I get it.
>
> Which process should I hook if I want to get Content-Length's ultimate
> value? Any suggestion?
>
> Many thanks!
>
> Vic
>
> --
> Best regards,
>
> Rui Hu
>
> ----------------------------------------------------------------------------------------
> State Key Laboratory of Networking & Switching Technology
> Beijing University of Posts and Telecommunications(BUPT)
> MSN: tchrbupt@gmail.com
>
> -----------------------------------------------------------------------------------------
>