Forums » Development »
[Solved] Dumping POST data
Added by jhilgeman about 16 years ago
(I apologize in advance if I use incorrect terminology. I'm a longtime Apache user looking at Lighttpd for the first time for performance reasons.)
I'm trying to put together a 1.4.20 lighttpd install that does nothing but dump the incoming POST data and return a 1-byte static HTML file (without using any sort of PHP / CGI / etc plugins). The idea here is basically that there will be up to a few thousand connections at any given time POSTing about 3-4k data each and then disconnecting.
I didn't see anything in the vanilla setup that would do this, so I looked at the source and tried to add this to mod_accesslog.c:
1. Added FORMAT_DUMP_BYTES_IN between FORMAT_BYTES_OUT and FORMAT_RESPONSE_HEADER in the struct's enum.
2. Added { 'Z', FORMAT_DUMP_BYTES_IN }, into the format_mapping between the same above two format items.
3. Added this chunk below the FORMAT_BYTES_IN case (in the REQUESTDONE_FUNC):
case FORMAT_DUMP_BYTES_IN: if (con->bytes_read > 0) { buffer_append_string_buffer(b, chunkqueue_get_append_buffer(con->read_queue)); } else { buffer_append_string_len(b, CONST_STR_LEN("-")); } break;
I cleaned up, reconfigured, recompiled, and gave it a try using my new %Z format in the accesslog.format config option. The result is basically just a blank string, so I've obviously done something wrong.
Is the read_queue cleared before the accesslog module is reached, maybe? Is there a better way of doing this, or has someone else done anything like it that I can't find?
Replies (2)
RE: Dumping POST data - Added by stbuehler about 16 years ago
Perhaps you should have read the code for chunkqueue_get_append_buffer...
There is just no function to get the content of the chunkqueue in a buffer.
RE: [Solved] Dumping POST data - Added by gstrauss about 8 years ago
mod_accesslog is the wrong place to do that.
You should write a handler, either FastCGI or SCGI or native C lighttpd module which reads the input, writes it do disk, and sets status code and response. Instead of one byte body, I would recommend returning HTTP status 204 No Content.