There is greater ambiguity when transforming POST to PUT than that which is described in the cited article. In the case of that article, the transform is for two methods of submitting html form variables. In the GET case, form variables are part of the request-uri, while in the POST case, they are embedded in the message body. Form variables are not submitted using the PUT method. It may be used to upload resources.
Alternatively, the methods in this case may be used as part of a so-called RESTful interface. Generally, since PUT is idempotent, it is used to create or replace a representation, and since POST is not idempotent, it has no specific interpretation, but is often used to amend a part of a representation.
I assume that the original request requires only the transform of the method, but does not require alteration of the request headers or the message body. Unhappily, you cannot use
HTTP::method
to change the HTTP method, so you do in fact have to use
TCP::collect
(as in the article). You can combine this with a data-group, which allows you to alter the match list without reloading the iRule. Create the data-group as follows:
tmsh create ltm data-group internal dg-post-transform-uris \
type string \
records add { \
"/data/rest/abc/list/shared/" {} \
"/data/rest/abc/list/tag/" {} \
"/data/rest/abc/group/" {} \
}
when CLIENT_ACCEPTED {
TCP::collect
}
when CLIENT_DATA {
if { [TCP::payload] starts_with "POST " } {
if { [class match [substr [TCP::payload] 5 " "] starts_with dg-post-transform-uris] } {
TCP::payload replace 0 4 "PUT"
}
}
}