On 29 May 2008, at 11:52, Stefan de Konink wrote:
> On Thu, 29 May 2008, Alvaro Lopez Ortega wrote:
>> On 29 May 2008, at 11:18, Stefan de Konink wrote:
>>
>>> While server_info itself can do only the add_buffer method? Is
>>> this a
>>> shortcut because it is assumed to be less that 8k?
>>
>> I don't think I have understood the question.
>
> Please elaborate on the use of:
>
> ret_t
> cherokee_handler_admin_step (cherokee_handler_admin_t *ahdl,
> cherokee_buffer_t *buffer)
> {
> cherokee_buffer_add_buffer (buffer, &ahdl->reply);
> return ret_eof_have_data;
> }
Well, the case of the "admin" handler is a little bit special.
It receives a request, and it parsers it and performs an action before
the reply is sent. Depending on what happens during the action the
answer will be different.
So, when the _step() method is invoked, it already has a buffer with
the full reply. The only thing it does is to copy the reply to the
server buffer. Besides, knowing that it is the last package (the only
one, actually) it returns ret_eof_have_data to let the server know
that it shouldn't call _step() any more.
Anyway, let's see what the common behavior is. For instance, this is
how a simplistic handler "file" would work:
1.- new(): It initializes the new object
2.- init(): It opens the file the will be read
3.- add_headers(): Checks size and adds the content-length header
4.- step(): read() in to the buffer and return ret_ok;
5.- step(): read() in to the buffer and return ret_ok;
6.- step(): read() in to the buffer and return ret_ok;
7.- step(): get an EOF from read() so it returns ret_eof;
So, in the case you would have known in advance that the chunk read on
stage 6 was the last one, you could have replied ret_eof_have_data,
and _step() wouldn't have been invoked the seventh time. (Do not worry
much about this, it's only a small optimization).
Does this help to clarify things?
--
Greetings, alo.
_______________________________________________
Cherokee mailing list
[email protected]
http://cherokee-project.com/cgi-bin/mailman/listinfo/cherokee