Forum Discussion
ML_108504
Nimbostratus
Apr 22, 2009HTTP::respond question on content
I'm attempting to compose an iRule where the F5 will respond with a standard JBoss 404 if there's a match to certain URIs.
I have two issues.
1. I want to insert the requested URI into the HTTP::respond content section, using the HTTP::uri command. Is this feasible? Do I need to use escape characters in order to use HTTP:: commands (or variables for that matter) inside of a HTTP::respond content section?
The code below just treats [HTTP::uri] as a text string.
HTTP::respond 404 content {JBossWeb/2.0.1.GA - Error report HTTP Status 404 - [HTTP::uri]type Status reportmessage [HTTP::uri]description The requested resource ([HTTP::uri]) is not available.JBossWeb/2.0.1.GA} noserver
2. This HTTP::respond command passes the following to the client, and I don't want the Connection and Content-Length headers passed this way. I'm not doing this explicitly, how can I prevent these two lines from appearing? I just want the section to be passed to the client, with the [HTTP::uri] value passed by the client.
Connection: Keep-Alive
Content-Length: 979
JBossWeb/2.0.1.GA - Error report HTTP Status 404 - [HTTP::uri]type Status reportmessage [HTTP::uri]description The requested resource ([HTTP::uri]) is not available.JBossWeb/2.0.1.GA
6 Replies
- hoolio
Cirrostratus
The outermost curly braces prevent variable expansion/interpretation of commands in TCL. You should be able to use subst (Click here) to force evaluation of the [HTTP::uri] command within the curly braces:
HTTP::respond 404 content [subst {test URI: [HTTP::uri] }] noserver
The Connection and Content-Length headers are inserted automatically. You could try setting a Connection: Close header, but I'm guessing it would be appended to the request and not replace the Connection: Keep-Alive header.
HTTP::respond 404 content [subst {test URI: [HTTP::uri] }] noserver Connection Close
And LTM needs to insert the Content-Length header in order to tell the client how much data will be sent.
Aaron - ML_108504
Nimbostratus
Ah. That answers both my questions. Good stuff to know. Hmmm, too bad about the 2nd point.
Thanks! - spark_86682Historic F5 AccountIf you really don't want the headers there, you could probably use TCP::respond instead.
- hoolio
Cirrostratus
Good point on TCP::respond. I'm just not sure what kind of client would handle data coming back with no Content-Length or Connection header. It seems like you would need at least one or the other for the client to accept the response.
Aaron - ML_108504
Nimbostratus
Hi guys, just to clarify:
The problem isn't that the bigip is sending those headers, the problem is that the two headers are appearing as text in the html page. In other words, I think my problem is that these headers are not actually being sent as headers.
Does that make sense? I think I need to bite the bullet and just trace the communication and post the relevant example up here. When I get time ... - hoolio
Cirrostratus
Can you try testing without the noserver flag? Which version are you testing this on?
Aaron
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