Skip to content

daemon/http: expose HTTP headers to kr_request

Tomas Krizek requested to merge expose-http-headers into master

(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
Edited by Lukas Jezek

Merge request reports