Forum Discussion
DarkSideOfTheQ_
Nimbostratus
Mar 27, 2009Change content-type and status code
OK, so I've been asked to change the status code and also the content-type for one of our apps. I know I can change the status code, but haven't done anything with changing the content-type. Can I do this in the same iRule and if so...how? Help is much appreciated.
Here is the iRule I've been using to change the status code for their app. (NOTE: I modified the 'content' returned to what they want to return now, before it was just "No Content")
when HTTP_REQUEST {
switch -glob [HTTP::host] {
"*server1.mydomain.com" -
"*server2.mydomain.com" -
"*server3.mydomain.com" -
"*server4.mydomain.com" {
HTTP::respond 200 content "%FDF-1.21 0 obj<> >>>>endobjtrailer<>%%EOF"
}
}
}
They would like to return the content-type of "application/vnd.fdf"
TIA,
DarkSide
- hoolio
Cirrostratus
You can add headers to the response with HTTP::respond. Also, you can consolidate the server using glob style wildcard matching:when HTTP_REQUEST { switch -glob [string tolower [HTTP::host]] { "*server[1-4].mydomain.com" { HTTP::respond 200 content {%FDF-1.21 0 obj<> >>>>endobjtrailer<>%%EOF} "Content-Type" "application/vnd.fdf" } } }
- DarkSideOfTheQ_
Nimbostratus
Hoolio - Thanks for the help with this. I've got another question about the content I'm try to return. The string I provided before had to be tweaked and once I put it in the LB, it gets some characters converted.
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