httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nick Kew <>
Subject Re: Basics on generating content
Date Sun, 27 May 2007 18:31:20 GMT
On Sun, 27 May 2007 11:05:10 -0700
Tim Bray <Tim.Bray@Sun.COM> wrote:

> I'll open this plea for advice by offering some free advice to other  
> module-writing newbies like me.  When you're trying to figure out
> wtf some piece of code, e.g. apr_xml_to_text, does, the following
> will get you the answer by example, most times:
>   find modules -name '*.c' -print | xargs egrep xml_to_text

Just grep your /include/ directory.

> Question: I'm generating output from a module.  How do the headers  
> get sent?

Constructed from r->headers_out and r->err_headers_out in the
HTTP protocol filter.

>	  mod_example suggests you should call send_http_header but  
> I can't find an example of any module actually doing this. 

Neither can I.
> Scenario:  I'm about to punt a request using HTTP_FORBIDDEN and I'd  
> like to generate a helpful response body explaining why.

The easy way is to delegate that to the admin with ErrorDocument.

>	  DAV does  
> this in modules/dav/main/mod_dav.c in dav_error_response, sets r- 
>  >status, calls ap_set_content type, fires off the data with rvputs,  
> and returns DONE.  Um... how do any accumulated headers get sent?
> Is it all just taken care of?

Yep.  That's an unusual way to do it.  A bit like nph is to CGI.

> Related: In that same mod_dav.c, there's this:

mod_dav is one of the most complex things in apache,
and contains incompleteness and fudges in places.
Are you implementing something that'll run under mod_dav?
If not, it's probably not a good learning resource.

Nick Kew

Application Development with Apache - the Apache Modules Book

View raw message