sending data in "chunks"
Manlio Perillo
manlio_perillo at libero.it
Sun Sep 16 22:08:09 MSD 2007
Igor Sysoev ha scritto:
> On Sun, Sep 16, 2007 at 07:36:49PM +0200, Manlio Perillo wrote:
>
>> I need to send to the client some data in chunks.
>> The data is read from a Python file like object.
>>
>> Right now I'm using a static ngx_chain_t variable, and for each cycle I
>> read data from the "file" object in a buffer and do:
>>
>> // allocate buf and b
>> out.buf = b;
>> out.next = NULL;
>>
>> b->pos = buf;
>> b->last = buf + n;
>>
>> b->memory = 1;
>> b->last_buf = 0;
>>
>> rc = ngx_http_output_filter(r, &out);
>> if (rc != NGX_OK) {
>> goto error;
>>
>>
>> Then at the end of the cycle, then, I do a
>>
>> return ngx_http_output_filter(r, NULL);
>>
>>
>> Unfortunately this does not works.
>> What is the right method for sending data in chunks?
>
> You should set b->last_buf in last buf.
> NULL is simply pump. It is used for exmple by default write handler
> to pass all buffered data to client.
>
Ok, thanks.
I have also found the real problem: one of the call to
ngx_http_output_filter fails with a return value -2.
Now I have to found the problem...
Regards Manlio Perillo
More information about the nginx
mailing list