toitlang / pkg-http

Package: Implement your REST server or client in Toit and run it on your ESP32.
MIT License
1 stars 1 forks source link

Get a list of incoming headers #120

Closed oscarcp closed 8 months ago

oscarcp commented 1 year ago

I would like to have a method or variable that returns a list with all the incoming headers (just the keys) in the Request object (same as Request.headers.headers_.keys)

Current output of Request.headers.headers_.keys

>> print Request.headers.headers_.keys
["User-Agent", "Host", "Connection"...]

Example:

import http
server := http.Server
server.listen tcp_socket:: | req/http.Request resp/http.ResponseWriter |
  // Output a list of keys ["User-Agent", "Host", "Connection"...]
  print req.headers.all 
  // Iterate over keys
  req.headers.all.do: print "$it"
floitsch commented 8 months ago

Will be available in the next release of the package.