Forum Discussion
eval is HTTP:response
I thought there was a way to include evaluated expressions in the HTTP:response command.
Something like
when HTTP_REQUEST {
HTTP::respond 200 content {
Pretend this is the web site.
HTTP::header "True-Client-IP": [HTTP::header "X-Forwarded-For"]
}
}
Is that possible?
This is to make testing easier.
Thanks! Ben
2 Replies
- Kevin_Stewart
Employee
You can definitely use evaluated expressions in an HTTP::respond command, but your example is a little off. You would include any HTTP headers AFTER the content. Example:
when HTTP_REQUEST { HTTP::respond 200 content "..." "True-Client-IP" [IP::client_addr] }Your example assumes the X-Forwarded-For header would be in the HTTP request, which the client (a browser) would not generally send. So if you need to send the client source address back to the client, you could simply use [IP::client_addr].
- Kevin_Stewart
Employee
I basically want to list the headers that F5 received, and or modified, in an HTTP::response
Okay. Please try this then:
when HTTP_REQUEST { set headerlist "" foreach x [HTTP::header names] { append headerlist "$x = [HTTP::header $x] " } HTTP::respond 200 content "Request Headers: $headerlist" }This will send back all of the client's request headers in formatted HTML.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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