[bug #54814] httpd dynamic file read

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

[bug #54814] httpd dynamic file read

madhu
URL:
  <https://savannah.nongnu.org/bugs/?54814>

                 Summary: httpd dynamic file read
                 Project: lwIP - A Lightweight TCP/IP stack
            Submitted by: vuahoa07
            Submitted on: Wed 10 Oct 2018 04:15:44 AM UTC
                Category: apps
                Severity: 3 - Normal
              Item Group: Faulty Behaviour
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
         Planned Release: None
            lwIP version: 2.1.0

    _______________________________________________________

Details:

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;
}




    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/bugs/?54814>

_______________________________________________
  Message sent via Savannah
  https://savannah.nongnu.org/


_______________________________________________
lwip-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-devel
Reply | Threaded
Open this post in threaded view
|

[bug #54814] httpd dynamic file read

madhu
Follow-up Comment #1, bug #54814 (project lwip):

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?

    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/bugs/?54814>

_______________________________________________
  Message sent via Savannah
  https://savannah.nongnu.org/


_______________________________________________
lwip-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-devel
Reply | Threaded
Open this post in threaded view
|

[bug #54814] httpd dynamic file read

madhu
Follow-up Comment #2, bug #54814 (project lwip):

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.

    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/bugs/?54814>

_______________________________________________
  Message sent via Savannah
  https://savannah.nongnu.org/


_______________________________________________
lwip-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-devel
Reply | Threaded
Open this post in threaded view
|

[bug #54814] httpd dynamic file read

madhu
Follow-up Comment #3, bug #54814 (project lwip):

> 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?

    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/bugs/?54814>

_______________________________________________
  Message sent via Savannah
  https://savannah.nongnu.org/


_______________________________________________
lwip-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-devel
Reply | Threaded
Open this post in threaded view
|

[bug #54814] httpd dynamic file read

madhu
Follow-up Comment #4, bug #54814 (project lwip):

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.

    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/bugs/?54814>

_______________________________________________
  Message sent via Savannah
  https://savannah.nongnu.org/


_______________________________________________
lwip-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-devel
Reply | Threaded
Open this post in threaded view
|

[bug #54814] httpd dynamic file read

madhu
Update of bug #54814 (project lwip):

                  Status:                    None => Works For Me          
             Assigned to:                    None => goldsimon              
             Open/Closed:                    Open => Closed                

    _______________________________________________________

Follow-up Comment #5:

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

    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/bugs/?54814>

_______________________________________________
  Message sent via Savannah
  https://savannah.nongnu.org/


_______________________________________________
lwip-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-devel
Reply | Threaded
Open this post in threaded view
|

[bug #54814] httpd dynamic file read

madhu
Follow-up Comment #6, bug #54814 (project lwip):

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).

    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/bugs/?54814>

_______________________________________________
  Message sent via Savannah
  https://savannah.nongnu.org/


_______________________________________________
lwip-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-devel
Reply | Threaded
Open this post in threaded view
|

[bug #54814] httpd dynamic file read

madhu
Follow-up Comment #7, bug #54814 (project lwip):

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.

    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/bugs/?54814>

_______________________________________________
  Message sent via Savannah
  https://savannah.nongnu.org/


_______________________________________________
lwip-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-devel