daemon/http: expose HTTP headers to kr_request
(Currently rebased on top of !1164 (merged))
Add HTTP headers to an optional kr_request.qsource.headers
structure.
Headers are stored as name, value string pairs.
In the configuration, headers to be exposed can be selected with net.doh_headers()
that takes either a string or a table of strings. These string are the names of headers that should be copied into kr_request.qsource.headers
. Comparison is case-insensitive and pseudo-headers are supported as well.
net.doh_headers({'accept', ':method'})
The following snippet can be used to access the headers in lua modules:
for i = 1, tonumber(req.qsource.headers.len) do
local name = ffi.string(req.qsource.headers.at[i - 1].name)
local value = ffi.string(req.qsource.headers.at[i - 1].value)
print(name, value)
end
Fixes #616 (closed)
TODO:
-
configuration interface to select which headers should be exposed -
expose only selected headers -
documentation -
config test
Merge request reports
Activity
added feature label
added 1 commit
- 81b607ef - fixup! daemon/http: expose HTTP headers to kr_request
added 1 commit
- 9c2221b6 - fixup! daemon/http: expose HTTP headers to kr_request
added 8 commits
- a796f573 - fixup! daemon/http: expose HTTP headers to kr_request
- 2167bd46 - doc/net.tls(): update command example output
- e54c87f5 - daemon/worker: add doh_headers_in list
- 17ae9f11 - daemon/http: expose only chosen headers and limit max value length
- 1d6f6e56 - fixup! daemon/worker: add doh_headers_in list
- 553c98e3 - lib/resolve: make qsource.headers a struct instead of pointer
- 246adf87 - bindings/net: rename to doh_headers()
- 72b8e5b5 - nitpick: fix lint:tidy warnings
Toggle commit listchanged milestone to %5.4.0
added 58 commits
-
d61b52bb...895cf6a9 - 48 commits from branch
master
- 2829f326 - daemon/http: use struct for http stream
- f4a1df9b - daemon/http: expose HTTP headers to kr_request
- 33cbdf3c - doc/net.tls(): update command example output
- b0fe8ce6 - daemon/worker: add doh_headers_in list
- e7cfd369 - daemon/http: expose only chosen headers and limit max value length
- 84b9ea95 - lib/resolve: make qsource.headers a struct instead of pointer
- 181bfe54 - bindings/net: rename to doh_headers()
- 63a90048 - nitpick: fix lint:tidy warnings
- 722c3928 - daemon/http: add expose headers config test
- baf0b528 - doc: add DoH configuration net.doh_headers
Toggle commit list-
d61b52bb...895cf6a9 - 48 commits from branch
mentioned in commit e0a7f139
This merge introduced memory leaks in a trivial test case I was now trying with Chrome for Android (just connect to
/doh
and accept the cert; EDIT: no config around the headers).ERROR: LeakSanitizer: detected memory leaks Direct leak of 48 byte(s) in 2 object(s) allocated from: #0 0x7f7cd7e7bbcf in __interceptor_malloc (libasan.so.6+0xb1bcf) #1 0x48703e in begin_headers_callback ../daemon/http.c:297 #2 0x7f7cd78b214c in nghttp2_session_on_request_headers_received (libnghttp2.so.14+0xe14c)
I wouldn't get any leaks with desktop Firefox for example, even if really using DoH for a while.
Edited by Vladimír Čunátmentioned in merge request !1191 (merged)