conditional_content_removal
Simulate the behavior of most web servers by removing the content of responses for HEAD requests, 1xx, 204, and 304 responses. Ensure compliance with RFC 9112 Section 6.3.
def conditional_content_removal(
request: HttpRequest,
response: HttpResponse
) - > HttpResponse
Simulate the behavior of most web servers by removing the content of responses for HEAD requests, 1xx, 204, and 304 responses. Ensure compliance with RFC 9112 Section 6.3.
Parameters
| Name | Type | Description |
|---|---|---|
| request | HttpRequest | The incoming HTTP request object used to check the request method. |
| response | HttpResponse | The outgoing HTTP response object whose content will be conditionally cleared. |
Returns
| Type | Description |
|---|---|
HttpResponse | The modified response object with the content body cleared if the status code or request method requires it. |