Wapp

HTTP headers
Login

HTTP headers

(1) By alx (alex) on 2020-01-21 19:48:21 [source]

Hello!

Is there  a way to get and set HTTP headers. Here is an example where I want to use JSON Web Token (https://en.wikipedia.org/wiki/JSON_Web_Token) with WAPP. For this I have to read and write the HTTP header "Authorization: Bearer nuhKJ4fSBDShs3...". Example:

proc wapp-page-restrequest {} {
  -> first I have to check the HTTP Header "Authorization: Bearer"
  do something
  -> now I have to set  the HTTP Header "Authorization: Bearer"

  wapp-mimetype application/json
  wapp-unsafe [encoding convertto utf-8 $json]
}

(2) By D. Richard Hipp (drh) on 2020-01-21 19:52:50 in reply to 1 [link] [source]

I think the HTTP headers are available if Wapp is run as a standalone server. But if it is run from CGI or SCGI, then the overlying webserver processes all that information and does not (normally) pass it along to the CGI/SCGI application, so there is no way for Wapp to see it.

I did not create an official API for accessing HTTP header elements since such an API would not be portable to CGI/SCGI deployments.