Skip to content

Latest commit

 

History

History
28 lines (24 loc) · 1.14 KB

221031.http.md

File metadata and controls

28 lines (24 loc) · 1.14 KB

2022-10-31

https://discordapp.com/channels/918498540232253480/918498540232253483/1036727344443949138

I have captive.portal working well. My phone connects to the ESP32 and toit serves a page with a form

that inputs an SSID and Password. When submitted, captive.portal reports the request:

handle request/http.Request writer/http.ResponseWriter -> none:
  path := request.path
    print "---------------------"
  print "Got request with path = $path length $request.content_length ."
  print "method=$request.method ver=$request.version"
  print "body=$request.body"
  print

and I see the following:

---------------------
Got request with path = /setssid.html length 0 .
method=POST ver=HTTP/1.1
body=an instance with class-id 18

Everything makes sense except I expected the body to contain my form data, like
ssid=xxx&password=yyy

kasperl

The body is a stream (Reader). You can read the bytes like here: https://github.com/toitlang/toit/blob/e0d0c04733afbdfca5c73ffbf540daf30a0d83ef/examples/http/http.toit#L14
Or you can try to parse the body in a streaming way (better if the body is big).