Forum Discussion
Tim_W_72292
Nimbostratus
Nov 19, 2007Adding to header and PDU content
Hi,
I am trying to add some content to a HTTP header and pdu content. I just need to add the bit in bold as shown in the example below:
POST /mms-rs/mm7 HTTP/1.1
Host: mms.om...
hoolio
Cirrostratus
Nov 19, 2007To insert the header, you can use the HTTP_REQUEST event:
when HTTP_REQUEST {
Insert HTTP header
HTTP::header insert start {}
}To insert the string in the payload, I thought you needed to collect the HTTP data first. I'm actually a bit surprised to see in the codeshare example HTTP::payload replace being used in the HTTP_RESPONSE event (as opposed to HTTP_RESPONSE_DATA).
If you do need to collect the data in order to modify the payload, I think it would actually be more efficient to use a stream profile to 'replace' a known string in the payload with that string plus what you want to insert.
Here's what I'm thinking for the rule:
when HTTP_REQUEST {
Check if the request is a POST to a specific path with a content type containing "xml"
if {[HTTP::path] starts_with "/mms-rs" and [HTTP::method] eq "POST" and [HTTP::header value "Content-Type" contains "xml"}{
Insert HTTP header
HTTP::header insert start {}
Enable the stream profile and set the find/replace strings
STREAM::enable
STREAM::expression {@Content-Type:text/xml; charset="utf-8"@Content-Type:text/xml; charset="utf-8"...Content-ID: @}
}
}The rule requires a blank stream profile added to the virtual server.
The stream expression format is described on the wiki page (Click here).
The only catch, is that I haven't figured out how to insert a carriage return and line feed where the three periods are in the STREAM::expression. I'm not sure if you could insert a \r\n, the value in hex 0D0A, or something else altogether. I can't test this right now to see either.
Aaron
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
