MCPcopy
hub / github.com/pallets/werkzeug / remove_entity_headers

Function remove_entity_headers

src/werkzeug/http.py:1163–1184  ·  view source on GitHub ↗

Remove all entity headers from a list or :class:`Headers` object. This operation works in-place. `Expires` and `Content-Location` headers are by default not removed. The reason for this is :rfc:`2616` section 10.3.5 which specifies some entity headers that should be sent. .. vers

(
    headers: ds.Headers | list[tuple[str, str]],
    allowed: t.Iterable[str] = ("expires", "content-location"),
)

Source from the content-addressed store, hash-verified

1161
1162
1163def remove_entity_headers(
1164 headers: ds.Headers | list[tuple[str, str]],
1165 allowed: t.Iterable[str] = ("expires", "content-location"),
1166) -> None:
1167 """Remove all entity headers from a list or :class:`Headers` object. This
1168 operation works in-place. `Expires` and `Content-Location` headers are
1169 by default not removed. The reason for this is :rfc:`2616` section
1170 10.3.5 which specifies some entity headers that should be sent.
1171
1172 .. versionchanged:: 0.5
1173 added `allowed` parameter.
1174
1175 :param headers: a list or :class:`Headers` object.
1176 :param allowed: a list of headers that should still be allowed even though
1177 they are entity headers.
1178 """
1179 allowed = {x.lower() for x in allowed}
1180 headers[:] = [
1181 (key, value)
1182 for key, value in headers
1183 if not is_entity_header(key) or key.lower() in allowed
1184 ]
1185
1186
1187def remove_hop_by_hop_headers(headers: ds.Headers | list[tuple[str, str]]) -> None:

Callers 1

get_wsgi_headersMethod · 0.85

Calls 1

is_entity_headerFunction · 0.85

Tested by

no test coverage detected