patchlwIP - A Lightweight TCP/IP stack - Patches: patch #9501, httpd: move httpd_cgi_handler()...


You are not allowed to post comments on this tracker with your current authentication level.

patch #9501: httpd: move httpd_cgi_handler() call

Submitted by:  Giuseppe Modugno <giusloq>
Submitted on:  Mon 27 Nov 2017 09:18:41 AM UTC  
Category:  apps Priority:  5 - Normal
Status:  Done Privacy:  Public
Assigned to:  Simon Goldschmidt <goldsimon> Open/Closed:  Closed
Planned Release:  2.1.0

Fri 02 Feb 2018 08:32:01 AM UTC, comment #2:

Applied, thanks for the patch.

Simon Goldschmidt <goldsimon>
Project AdministratorIn charge of this item.
Thu 01 Feb 2018 06:58:27 PM UTC, comment #1:

> IMHO another good modification could be to pass file to httpd_cgi_handler()

That would be good, too, indeed.

Simon Goldschmidt <goldsimon>
Project AdministratorIn charge of this item.
Mon 27 Nov 2017 09:18:41 AM UTC, original submission:

This patch moves in advance httpd_cgi_handler() call, before assigning variables like hs->file and hs->left.

In this way, CGI handler could prepare the reply data and set the "file properties", like file->data and file->len. At the exit, hs->file and hs->left is correctly assigned.
The handler prototype says it can't access file pointer, however it is simple to obtain it after setting LWIP_HTTPD_FILE_STATE that enables a "file state" pointer. It is sufficient to assign file->state to file itself in fs_open_custom().

For example, I have the request GET /login.cgi?user=admin&pwd=admin and I have to reply with some JSON data. The answer depends on parameters user and pwd passed in the query string.

I can't create the answer in fs_open_custom(), because parameters aren't available. Even the answer buffer can't be allocated in fs_open_custom(), because the answer length isn't known in advance. In CGI handler I can allocate and create the answer.

This could work only if my patch is applied.

IMHO another good modification could be to pass file to httpd_cgi_handler(), instead of only file->state. In the handler, you will have the access to file and file->state. With this change, you could avoid assigning file->state=file in fs_open_custom().

Giuseppe Modugno <giusloq>


Attached Files
file #42496:  patch.diff added by giusloq (2KiB - application/octet-stream)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by goldsimon (Updated the item)
  • -email is unavailable- added by giusloq (Submitted the item)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.




    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-02-02 goldsimon StatusNone => Done
        Assigned toNone => goldsimon
        Open/ClosedOpen => Closed
    2018-01-02 goldsimon Planned ReleaseNone => 2.1.0
    2017-11-27 giusloq Attached File- => Added patch.diff, #42496

    Back to the top

    Powered by Savane 3.4