buglwIP - A Lightweight TCP/IP stack - Bugs: bug #54814, httpd dynamic file read

 
 

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

bug #54814: httpd dynamic file read

Submitter:  Vua Hoa <vuahoa07>
Submitted:  Wed 10 Oct 2018 04:15:44 AM UTC
   
 
Category:  apps Severity:  3 - Normal
Item Group:  Faulty Behaviour Status:  Works For Me
Privacy:  Public Assigned to:  goldsimon
Open/Closed:  Closed Planned Release:  None
lwIP version:  2.1.0

Jump to the original submission

Tue 30 Oct 2018 08:15:27 PM UTC, comment #7: 

Yeah, well, you get one member for private data. If you need more, you need to allocate a struct.

There are files that can be fully created in the "open" callback. In this case, there's no need to call fs_read_custom.

file->data is what the httpd sends out. This could change in a rework that I am planning, but for now, it's like that. Feel free to post documentation update if this was misleading for you.

Simon Goldschmidt <goldsimon>
Group administrator
Tue 30 Oct 2018 11:53:02 AM UTC, comment #6: 

I did use file->pextension. At first time using dynamic reading, I use 'file->pextention' to store request information (ex: uri) and use 'file->data' for response information (file handle, status...). But if 'file->data' not NULL, the read function is not called, so i have to group all information to 'pextension' only. Of course, we can add other fields to fs_file struct but this is informal.
Here i want to talk about the logic of the calling: the fs_read_custom shall always be called to feed data; the httpd shall not automatically load data (even from file->data).

Vua Hoa <vuahoa07>
Tue 30 Oct 2018 08:25:49 AM UTC, comment #5: 

OK, then just use file->pextension, which is meant for what you want instead of file->data.

Simon Goldschmidt <goldsimon>
Group administrator
Tue 30 Oct 2018 08:20:50 AM UTC, comment #4: 

I want to use file->data to store File handle (in fs_open_custom) for later reading (used by fs_read_custom). Without that, i have to manage a http-request/file-handle mapping table.

Vua Hoa <vuahoa07>
Mon 29 Oct 2018 08:10:32 AM UTC, comment #3: 


> The bug I see here is for the 2nd options (LWIP_HTTPD_DYNAMIC_FILE_READ = 1): when file->data != NULL,
> httpd use this pointer to send out data, it does not call fs_read_custom.


OK, so why is file->data != NULL for custom reads? Can't you just set it to NULL for a file where you want fs_read_custom() to be called?

Simon Goldschmidt <goldsimon>
Group administrator
Wed 10 Oct 2018 02:06:07 PM UTC, comment #2: 

First, sorry for the wrong comments, it should be 'fs_read_custom' instead of 'fs_open_custom'.
I think the two options work as following:
1. LWIP_HTTPD_CUSTOM_FILES = 1 -> user app should provide fs_open_custom to feed file data buffer to the file->data pointer, and the httpd can use file->data directly.
2. LWIP_HTTPD_DYNAMIC_FILE_READ = 1 -> the httpd should ALWAYS call fs_read_custom to feed data before each sending, it should NOT use file->data. User App can set file->data to a specific value (maybe used later in the fs_read_custom), and httpd shall NOT use it.

The bug I see here is for the 2nd options (LWIP_HTTPD_DYNAMIC_FILE_READ = 1): when file->data != NULL, httpd use this pointer to send out data, it does not call fs_read_custom.

Vua Hoa <vuahoa07>
Wed 10 Oct 2018 01:06:10 PM UTC, comment #1: 

So what's the bug here? Sending from file->data is perfectly valid if your custom open function supports it?

Do you have a suggested change? Is file->data somehow uninitialized as default?

Simon Goldschmidt <goldsimon>
Group administrator
Wed 10 Oct 2018 04:15:44 AM UTC, original submission:  

Settings:
 LWIP_HTTPD_CUSTOM_FILES = 1
 LWIP_HTTPD_DYNAMIC_FILE_READ = 1

The httpd/fs still send data directly from file->data buffer after fs_open_custom(...) instead of calling fs_read_custom (to feed a chunk of file).
I have to set file->data = NULL (inside fs_open_custom) to make http call fs_read_custom:

int fs_open_custom(struct fs_file *file, const char *name)
{
  ... open file...

  /*
  file->data = (const char *)p_web->buf_ptr; -> will not call 'fs_open_custom'
  */
  file->data = NULL; // Will call 'fs_open_custom'
  file->len = p_web->size;
  file->index = 0;
  file->pextension = p_web->buf_ptr;
  file->flags = FS_FILE_FLAGS_HEADER_INCLUDED;

  return 1;
}

Vua Hoa <vuahoa07>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by goldsimon (Posted a comment)
  • -email is unavailable- added by vuahoa07 (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-10-30 goldsimon StatusNone Works For Me
        Assigned toNone goldsimon
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code