Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serving POST request via HTTPS #3211

Open
Somritag opened this issue Aug 23, 2024 · 4 comments
Open

Serving POST request via HTTPS #3211

Somritag opened this issue Aug 23, 2024 · 4 comments

Comments

@Somritag
Copy link

Hi Andy,
ISSUE: Serving POST request via HTTPS only when the file is not available in mount point

While testing the minimal-http-server-form-post.c encountered a scenario where the /form1 in index.html is checked which is not available in the mount location.
image
so in lws_http_serve() wsi->http.fop_fd returns unable to open and return 1-> which is the value of m and enters m>0 loop.
and proceeds further to land in LWS_CALLBACK_HTTP_BODY from lws_read_h1

Our scenario is : mount point has a file userlogin.html , from where I get the text type name login and password , formaction is userlogin.html which is present in the mount. So lws_http_serve returns 0 (as we are able to open that file) and it's not landing to the callback for processing the POST request.

Attaching wireshark capture for userlogin.html post pkt
image

Wanted to know is this the way serving POST request is designed or am I missing something?
Creating the context as below :
image

Callback looks like this :
image

Thanks,
Som

@Somritag
Copy link
Author

Hi Andy,

Any Suggestions towards this ?

@Somritag
Copy link
Author

Somritag commented Sep 5, 2024

Just to summarize the above query ->
Is there any limitation while serving POST request. As the sample example also has /form1 in index.html which is unavailable in the mount location, the request lands in LWS_CALLBACK_HTTP_BODY after lws_http_serve function in server.c

While what if the file from where the POST is available in the mount ?
I observed in my application if the file exist in the mount point the lws_http_serve returs m= 0 , and this case LWS_CALLBACK_HTTP_BODY in the callback is not getting triggered.

Thanks,

@lws-team
Copy link
Member

If I understood it, does this help?

diff --git a/lib/roles/http/server/server.c b/lib/roles/http/server/server.c
index 1986ba0b..73e35c2d 100644
--- a/lib/roles/http/server/server.c
+++ b/lib/roles/http/server/server.c
@@ -1826,7 +1826,9 @@ lws_http_action(struct lws *wsi)
        /* can we serve it from the mount list? */
 
        wsi->mount_hit = 0;
-       hit = lws_find_mount(wsi, uri_ptr, uri_len);
+       hit = 0;
+       if (!lws_hdr_total_length(wsi, WSI_TOKEN_POST_URI)
+               hit = lws_find_mount(wsi, uri_ptr, uri_len);
        if (!hit) {
                /* deferred cleanup and reset to protocols[0] */
 

@Somritag
Copy link
Author

Somritag commented Oct 3, 2024

Yeah this really helped. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants