Forum Discussion
hu_127869
Dec 16, 2005Historic F5 Account
How to rewrite the status from 205 to 200
Hi :
I would like to rewrite http status code 205 to 200. I try to use http:respond 200 , However, the payload is erased , Any good sample for me to rewrite the status code and also keep my o...
bl0ndie_127134
Dec 16, 2005Historic F5 Account
Hmm good question! Unfortunately for some reason our HTTP developer did not provide any way to change the response code, but that does not mean you can’t do it. There are a couple of approaches to this problem.
If you know ahead of time that you will be getting a 205 request (special request method, request cookie etc) then you can do a TCP::collect on the server side and replace the response code using TCP::payload replace.
If if you don’t have the priveledge of knowing this ahead of time, you will need to write some thing like this ...
when HTTP_RESPONSE {
if {[HTTP::status] == 205}{
HTTP::collect [HTTP::header Content-Length]
}
}
when HTTP_RESPONSE_DATA {
HTTP::respond 200 content [HTTP::payload]
}
The first approach while a little bit more difficult, can be more superior because you will not be buffering unnecessary payload. But if the 205 response payload size is not very large then I would go with the second one.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects
