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

Server gives a 400 Bad Request error #37

Open
luffmanm opened this issue Oct 17, 2021 · 1 comment
Open

Server gives a 400 Bad Request error #37

luffmanm opened this issue Oct 17, 2021 · 1 comment

Comments

@luffmanm
Copy link

luffmanm commented Oct 17, 2021

I am using a wifi device that connects to a host application running the http server. When the device logs on, it sends an http post in the following format:

POST HTTP/1.1
Host: 192.168.10.172:8080
Keep-Alive: 115
Connection: keep-alive
Content-Length: 98
Content-Type: application/x-www-form-urlencoded

user=demo&pswd=password&termID=000666213dfd&serverID=XXXXX+XXXX+Demo&PID=000&CKS=099&termdata=0%0F

The Ceen server however always responds with a "400 Bad Request" error with no information. I think the form post is properly formatted. Any suggestions as to how I would debug this to find out what the problem is?

Ok, I'm posting this edit because I figured it out. The server chokes on line 255 in HttpRequest.cs. The reason is that there are two spaces after "POST" in the header and no path to a handler is specified. Would it be reasonable to modify the code such that if the path is empty, "/" is assumed?

@kenkendk
Copy link
Owner

kenkendk commented Jul 29, 2022

The HTTP specification mentions that it is not allowed to have an empty path:
https://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html

Specifically it says:

Note that the absolute path cannot be empty; if none is present in the original URI, it MUST be given as "/" (the server root).

My reading of this is that the client MUST insert / if there is no path in the URL. Can your device change the request url to have a trailing slash? I am guessing it right now uses http://example.com but could perhaps use http://example.com/ ?

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