Skip to main content

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

NameTypeDescription
requestHttpRequestThe incoming HTTP request object used to check the request method.
responseHttpResponseThe outgoing HTTP response object whose content will be conditionally cleared.

Returns

TypeDescription
HttpResponseThe modified response object with the content body cleared if the status code or request method requires it.