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 Charles Fry <fr...@google.com> on 2008/02/15 17:18:47 UTC

ap_setup_client_block and Content-Length

Hi,

I desire to access a request's Content-Length from an input filter.
The only way I've been able to determine to do this short of manually
parsing the header myself is to call ap_setup_client_block and then
read r->remaining, but I don't see any precedent for doing this in
other modules (that said, none of them seem to care about
Content-Length at all). Reading the code, I don't see any reason why I
shouldn't be calling ap_setup_client_block even if I don't use
ap_should_client_block and ap_get_client_block, but since I don't see
anyone else doing this I wanted to double-check. Any advise on the
matter would be appreciated.

thanks,
Charles

Re: ap_setup_client_block and Content-Length

Posted by Moacir Schmidt <mo...@gmail.com>.
Have you tried:

apr_table_get(r->headers_in, 'Content-Length');

?

On Fri, Feb 15, 2008 at 1:18 PM, Charles Fry <fr...@google.com> wrote:

> Hi,
>
> I desire to access a request's Content-Length from an input filter.
> The only way I've been able to determine to do this short of manually
> parsing the header myself is to call ap_setup_client_block and then
> read r->remaining, but I don't see any precedent for doing this in
> other modules (that said, none of them seem to care about
> Content-Length at all). Reading the code, I don't see any reason why I
> shouldn't be calling ap_setup_client_block even if I don't use
> ap_should_client_block and ap_get_client_block, but since I don't see
> anyone else doing this I wanted to double-check. Any advise on the
> matter would be appreciated.
>
> thanks,
> Charles
>

RE: ap_setup_client_block and Content-Length

Posted by Brian Smith <br...@briansmith.org>.
Nick Kew wrote:
> "Charles Fry" <fr...@google.com> wrote:
> 
> > Hi,
> > 
> > I desire to access a request's Content-Length from an input filter.
> 
> When it exists, you can get it with
> apr_table_get(r->headers_in, "Content-Length")

There is no way to get an accurate content length if other input filters
have modified the request body's length ahead of yours. For example, try
putting mod_deflate's input filter before yours in the filter chain,
send a "Content-Encoding: deflate" request, and notice that mod_deflate
changed the input length without updating "Content-Length" or anything
else you can use to retrieve how much data you will actually get.

The *only* way to reliably tell how much input is available to your
filter/content-handler is to read all the input until you get to the EOS
bucket or until ap_get_client_block returns 0, counting the bytes along
the way. 

- Brian


Re: ap_setup_client_block and Content-Length

Posted by Charles Fry <fr...@google.com>.
Right, but then I have to parse it myself, and basically repeat all of
the work of ap_setup_client_block, which I would have preferred to
avoid...

Charles

On Fri, Feb 15, 2008 at 11:25 AM, Nick Kew <ni...@webthing.com> wrote:
> On Fri, 15 Feb 2008 11:18:47 -0500
>  "Charles Fry" <fr...@google.com> wrote:
>
>  > Hi,
>  >
>  > I desire to access a request's Content-Length from an input filter.
>
>  When it exists, you can get it with
>  apr_table_get(r->headers_in, "Content-Length")
>
>
>  --
>  Nick Kew
>
>  Application Development with Apache - the Apache Modules Book
>  http://www.apachetutor.org/
>

Re: ap_setup_client_block and Content-Length

Posted by Nick Kew <ni...@webthing.com>.
On Fri, 15 Feb 2008 11:18:47 -0500
"Charles Fry" <fr...@google.com> wrote:

> Hi,
> 
> I desire to access a request's Content-Length from an input filter.

When it exists, you can get it with
apr_table_get(r->headers_in, "Content-Length")


-- 
Nick Kew

Application Development with Apache - the Apache Modules Book
http://www.apachetutor.org/