sending data in "chunks"

Igor Sysoev is at rambler-co.ru
Sun Sep 16 21:43:46 MSD 2007


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.


-- 
Igor Sysoev
http://sysoev.ru/en/





More information about the nginx mailing list