Forum Discussion
is it possible to log all header to html page
- Apr 12, 2021
1.You can just add the log local0 in statement in the foreach loop and not write all the headers to "LogString" variable like log local0. "$headerName:[HTTP::header value $headerName]" or you can still use "LogString" but without the "append" as this time it will just take the value of the firt header and log it, then the second and then the 3th header and value and so on.
2.Also you can also research the Split string ?splitChars? to split the string in a list before logging the output "LogString" variable, so that you can make it a list (you add something like "#" after each append of the HTTP header and value and use it as match for the split string) beffore logging it out but the previous example is easyer.
Use of manipulations like "Split string" etc.:
https://devcentral.f5.com/s/articles/irules-101-15-tcl-list-handling-commands
I suggest reading the F5 devcental course on irules, so that you can work better with irules. After that play writting irules and in no time you are good to go as I see you are playng with them but just need some more time.
Hi Nikoolayy1,
Thank you for your detailed answer.
I change the order of the event "HTTP::respond", and it can log all headers in a response page =)
when HTTP_REQUEST {
set LogString "Client [IP::client_addr]:[TCP::client_port] -> [HTTP::host][HTTP::uri]</BR>"
log local0. "============================================="
log local0. "$LogString (request) - request: [HTTP::method]"
foreach headerName [HTTP::header names] {
append LogString "$headerName:[HTTP::header value $headerName]"
}
HTTP::respond 200 content "$LogString"
log local0. "Log content $LogString"
}
I just want to see the request header that is sent from the client for troubleshooting, and that's why i didn't use the "HTTP_RESPONSE". But now i facing the another problem is i can't delimit the multiple header name and its header value, it's because "append string", all header has been concatenated.
Regards,
Ding
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com