From my understanding, the requirement here is to present JSON content back to the requestor in the event that the JSON request triggers an ASM blocking page. What about something like the following:
when HTTP_REQUEST {
if { [HTTP::header "Content-Type"] contains "json" } {
set json_content 1
} else {
set json_content 0
}
}
when ASM_REQUEST_BLOCKING
{
if { $json_content }
{
HTTP::header remove Content-Length
HTTP::header insert header_1 value_1
set response "{ \"glossary\": { \"title\": \"example glossary\", \"GlossDiv\": { \"title\": \"S\", \"GlossList\": { \"GlossEntry\": { \"ID\": \"SGML\", \"SortAs\": \"SGML\", \"GlossTerm\": \"Standard Generalized Markup Language\", \"Acronym\": \"SGML\", \"Abbrev\": \"ISO 8879:1986\", \"GlossDef\": { \"para\": \"Request has been blocked.\", \"GlossSeeAlso\": \[\"GML\", \"XML\"\] }, \"GlossSee\": \"markup\" } } } } }"
ASM::payload replace 0 [ASM::payload length] ""
ASM::payload replace 0 0 $response
}
}