Luukdegram / apple_pie

Basic HTTP server implementation in Zig
MIT License
163 stars 21 forks source link

add `scheme` field/method to `Url` #69

Closed nektro closed 2 years ago

nektro commented 2 years ago

trying to implement a function that can detect if the request was made with HTTPS, so i need this in conjunction with the headers

nektro commented 2 years ago

optional but would recommend using https://github.com/MasterQ32/zig-uri

Luukdegram commented 2 years ago

This information is not available to the server. Clients will only send the host as part of the 'host' header (which is also only required for HTTP 1.1) and the path (as part of the HTTP spec). The scheme is simply unavailable to be determined by Apple Pie. The fact there's a proxy server in front of it, serving TLS, is information not available to the server. If you want to verify if the request was made with HTTPS, it must be done within the proxy server. Another option is to check the x-forwarded-proto header that most proxy servers set before proxying the request to the actual server.

I will however upstream my URI parser/builder that I created for my Gemini server, as I do see the usefulness of such a tool. I will leave this issue open until that is upstreamed.