|
From: | Giuseppe Modugno |
Subject: | Re: [lwip-users] httpd: how to implement AJAX |
Date: | Wed, 22 Nov 2017 17:07:13 +0100 |
User-agent: | Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 |
Il 13/11/2017 21:25, address@hidden ha scritto:Giuseppe Modugno wrote:I'm trying to implement what you wrote, using "custom files" instead of SSI. I think something doesn't work. Suppose I have a CGI script that the client requests with a GET /login.cgi?auth=pippo:pluto fs_open_custom() returns 1 if "login.cgi" is passed as filename. However here I'm not able to create the answer, because I need to evaluate the query string parameters (that I will do in CGI handler). So I can't do much in fs_open_custom() and I don't know how to set file->data, file->line and file->index. In CGI handler I'm ready to create the full answer because I have the query string, maybe in a buffer allocated with malloc and saved in file->state pointer. The problem here is fs_read_custom() is never called, because LWIP_HTTPD_DYNAMIC_FILE_READ isn't defined. Is really needed to define LWIP_HTTPD_DYNAMIC_FILE_READ in this scenario? This macro will allocate a dynamic output buffer in http_state and call fs_read_custom() that will limit to copy all or part of data created in CGI to the buffer of http_state. It seems too complex for this scenario. In CGI handler I could set all the "file info" in http_state (length and pointer), however http_state isn't accessible from this point. One thing I can't understand. It's index member of struct fs_file. It is initialized as the length of file content if fs_open(), for non custom files. And it is used in: int fs_bytes_left(struct fs_file *file) { return file->len - file->index; } So after fs_bytes_left() is zero immediately after fs_open(). This sounds strange to me. Maybe index isn't the pointer to unsent data (it should be zero after open), but to the pointer of the next byte to read from file (and for "static" files, there's no other data to read after open, because all data is ready immediately). |
[Prev in Thread] | Current Thread | [Next in Thread] |