简体   繁体   中英

When using lighttpd, mod_magnet and lua, can I access the raw request headers?

For a PoC I'm building I need to emulate the TRACE method in lighttpd. Using mod_magnet and lua I can reconstruct the request using the method/version/headers functions. But by doing so, the header order, case etc will be changed from the original.

Is it possible to improve upon this by accessing the raw headers, as received? Or is there a better way to achieve the desired outcome?

https://wiki.lighttpd.net/DebugVariables

debug.log-request-header = "enable"

If you need access to the raw bytes as lighttpd processes them, then you will need to modify the lighttpd source code.

In the end I just used the mod_magnet module plus LUA, and whilst not perfect, it is actually close enough not to matter. Et voilla, a TRACE response:

lighty.header["Content-Type"] = "message/http" 
lighty.r.resp_body.add(lighty.r.req_attr["request.method"] .. " " .. lighty.r.req_attr["request.orig-uri"] .. " HTTP/1.1\n")
for k, v in pairs(lighty.r.req_header) do
    lighty.r.resp_body.add( k .. ": " .. v .. "\n")
end
lighty.r.resp_body.add( "\n" )
return 200

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM