1 ### Tests for directives altering how a response is handled
3 # SecResponseBodyMimeTypesClear
6 comment => "SecResponseBodyMimeTypesClear",
9 SecResponseBodyAccess On
10 SecResponseBodyMimeTypesClear
11 SecDebugLog $ENV{DEBUG_LOG}
13 SecRule RESPONSE_BODY "TEST" "phase:4,deny"
16 -error => [ qr/Access denied/, 1 ],
17 debug => [ qr/Not buffering response body for unconfigured MIME type/, 1 ],
22 request => new HTTP::Request(
23 GET => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/test.txt",
27 # SecResponseBodyAccess & SecResponseBodyMimeType
30 comment => "SecResponseBodyAccess On",
33 SecDebugLog $ENV{DEBUG_LOG}
35 SecResponseBodyAccess On
36 SecResponseBodyMimeType text/plain null
37 SecRule RESPONSE_BODY "TEST" "phase:4,deny"
40 error => [ qr/Access denied with code 403 \(phase 4\)\. Pattern match "TEST" at RESPONSE_BODY\./, 1 ],
45 request => new HTTP::Request(
46 GET => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/test.txt",
51 comment => "SecResponseBodyAccess Off",
54 SecDebugLog $ENV{DEBUG_LOG}
56 SecResponseBodyAccess Off
57 SecResponseBodyMimeType text/plain null
58 SecRule RESPONSE_BODY "TEST" "phase:4,deny"
61 -error => [ qr/Access denied/, 1 ],
62 debug => [ qr/Response body buffering is not enabled\./, 1 ],
67 request => new HTTP::Request(
68 GET => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/test.txt",
72 # SecResponseBodyLimit
75 comment => "SecResponseBodyLimit (equal)",
78 SecResponseBodyAccess On
79 SecResponseBodyMimeType text/plain null
80 SecResponseBodyLimit 8192
83 -error => [ qr/Content-Length \(\d+\) over the limit/, 1 ],
88 request => new HTTP::Request(
89 GET => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/8k.txt",
94 comment => "SecResponseBodyLimit (less)",
97 SecResponseBodyAccess On
98 SecResponseBodyMimeType text/plain null
99 SecResponseBodyLimit 9000
102 -error => [ qr/Content-Length \(\d+\) over the limit/, 1 ],
107 request => new HTTP::Request(
108 GET => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/8k.txt",
113 comment => "SecResponseBodyLimit (greater)",
116 SecResponseBodyAccess On
117 SecResponseBodyMimeType text/plain null
118 SecResponseBodyLimit 8000
121 error => [ qr/Content-Length \(\d+\) over the limit \(8000\)\./, 1 ],
126 request => new HTTP::Request(
127 GET => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/8k.txt",
131 # ResponseBodyLimitAction
134 comment => "SecResponseBodyLimitAction Reject",
137 SecResponseBodyAccess On
138 SecResponseBodyMimeType text/plain null
139 SecResponseBodyLimit 5
140 SecResponseBodyLimitAction Reject
143 error => [ qr/Content-Length \(\d+\) over the limit \(5\)\./, 1 ],
148 request => new HTTP::Request(
149 GET => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/8k.txt",
154 comment => "SecResponseBodyLimitAction ProcessPartial",
157 SecResponseBodyAccess On
158 SecResponseBodyMimeType text/plain null
159 SecResponseBodyLimit 5
160 SecDebugLog $ENV{DEBUG_LOG}
162 SecResponseBodyLimitAction ProcessPartial
165 -error => [ qr/Content-Length \(\d+\) over the limit/, 1 ],
166 debug => [ qr/Processing partial response body \(limit 5\)/, 1 ],
171 request => new HTTP::Request(
172 GET => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/8k.txt",