[OpenWrt-Devel] uhttpd: chunked output from cgi script

Luigi Tarenga luigi.tarenga at gmail.com
Thu Oct 8 06:47:33 EDT 2015


thank you Jow for the promptly feedback.
I tried to better understand the problem and now I'm reading at your commit.
My patch works but is logically broken. I'm trying to produce a better one.

If I'm not wrong the problem is this (without applying your commit):
the client request handling code go though 3 steps (callback):
CLIENT_STATE_INIT -> client_init_cb ()
CLIENT_STATE_HEADER -> client_header_cb ()
CLIENT_STATE_DATA -> client_data_cb ()

actually in the INIT portion we test for the http_code 204 or 304 but 
this is wrong,
we still don't know if the client cached file is updated or not and I 
think the chunking
code apply only to data, not headers. a 204 message have no data.
this test should be done in the HEADER phase (uf_file_data call -> 
uf_file_if_unmodified_since)

If for testing purpose we completely skip this test I think it's safe 
because in the
HEADER phase (file.c line 617) if we are going to handle a file request 
we disable
chunked writes. If we are going to handle a script this does not happens.

to this add the fact that when we are going to execute a script after a 
file has been
handled there is no place where cl->http_code get resetted. this trigger 
the bug.
(for scripts only req->redirect_status = 200 is executed, file.c line 827)

I'm going to try a new simple patch and then your suggested one.
I will update you.

regards
Luigi


On 10/08/2015 12:21 AM, Jo-Philipp Wich wrote:
> Hi Luigi,
>
> thank you for your patch proposal, it prompted me to take a deeper look
> into the problem.
>
> The issue should be fixed with the following commit:
>
> http://nbd.name/gitweb.cgi?p=uhttpd2.git;a=commitdiff;h=7ed2edc40dd6d0171266f3bfbc96466e1d25e3cd
>
>
> Regards,
> Jow
>
>
>
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel at lists.openwrt.org
> https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.infradead.org/pipermail/openwrt-devel/attachments/20151008/7b93ed13/attachment.htm>
-------------- next part --------------
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list