Skip to content
Snippets Groups Projects

daemon/http: expose HTTP headers to kr_request

Merged 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

Pipeline #82307 failed

Pipeline failed for baf0b528 on expose-http-headers

Approval is optional

Merged by Tomas KrizekTomas Krizek 3 years ago (May 24, 2021 1:44pm UTC)

Merge details

Pipeline #82429 passed with warnings

Pipeline passed with warnings for e0a7f139 on master

Deployed to OBS/knot-‎dns-devel‎ 3 years ago

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
Please register or sign in to reply
Loading