-
Notifications
You must be signed in to change notification settings - Fork 196
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
wioterminal: webserver example fails with 'malformed HTTP request "G"' #476
Comments
I think I reproduced it in my environment. Perhaps a return value check is needed here. Line 69 in 81bc1bc
I will check a little more. |
Hi, thanks for looking into this. I have a rough fix that ran over night. The diff is below. Again, I don't have any documentation on the rpc firmware, so just making some educated guesses here. This tries up to 10x to read into the buffer. If the read result == -1, we retry again. The worst case I saw was 4 retries. This only works if the whole http request is contained in the first successful read. If the read returns only a portion of the http request, we need to continue reading until end of the request (CR/LF/CR/LF) + body. but for my testing, it seems each http request is fetched with a single read. I'm not sure why the second read into buf2 is there, or why four more reads happen before close, so I commented out that code and things still work.
|
I have created a tinygo driver in the following way
Much of the information can be found below.
|
Just a note for now: this issue is fixed with the netdev branch. |
Fixed by #537. |
In testing the wioterminal webserver example I bumped into a bug.
tinygo flash -target wioterminal -serial usb examples/rtl8720dn/webserver/main.go
The test is to repeatedly make an HTTP request for /hello. The webserver will return an HTTP response of "hello". The test runs for a few (10-100) iterations, returning the correct HTTP response of "hello", but then dies with:
malformed HTTP request "G"
The test is:
$ while true; do curl 192.168.1.60/hello; done
,where 192.168.1.60 is my wioterminal webserver address.
Attached is a minicom capture with debug=true and a few extra printfs I added to analyze. (Go to bottom to see error).
minicom.cap.malformed.log
Analysis
rtl87820dn/http.go:handleHTTP() is ignoring return result (-1) when calling Rpc_lwip_recv(). It looks like Rcp_lwip_recv() reads 1 byte into buf, so len(buf) > 0 and reading into buf is done. The one byte in buf is 'G'. (My guess is this is left over from a previous successful read request of "Get /hello HTTP/1.1"). But, the result value from the recv() call is -1, which handleHTTP() ignores. (I don't have documentation on the Rpc firmware to know the meanings on the result value, so some speculation on my part here as to what is a good result vs. bad result).
The text was updated successfully, but these errors were encountered: