httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Bray <Tim.B...@Sun.COM>
Subject Basics on generating content
Date Sun, 27 May 2007 18:05:10 GMT
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

and if that doesn't help, then the deep-dive:

  find . -name '*.[ch]' -print | xargs egrep xml_to_text

where is that stupid ap_* function declared/defined?

find . -name '*.[ch]' -print | xargs egrep 'DECLARE.*ap_rputs'

Question: I'm generating output from a module.  How do the headers  
get sent?  mod_example suggests you should call send_http_header but  
I can't find an example of any module actually doing this.   
Scenario:  I'm about to punt a request using HTTP_FORBIDDEN and I'd  
like to generate a helpful response body explaining why.  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?

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

     /* Apache doesn't allow us to set a variable body for  
      * we must manufacture the entire response. */

and also

** dav_error_response()
** Send a nice response back to the user. In most cases, Apache doesn't
** allow us to provide details in the body about what happened. This
** function allows us to completely specify the response body.
** ### this function is not logging any errors! (e.g. the body)

In general, are these comments correct, and is how DAV does things a  
good example of how to deal with a situation in which you're going to  
return oddities like 201 or 405 (very different kinds of things, I  
know) and want to control the body?  Returning DONE is a necessity?   
So I guess you're on your own for logging then?


View raw message