Secure.set_headers_async()

Apply configured headers asynchronously to response.

Usage

Source

Secure.set_headers_async(response)

This method is designed for async frameworks such as FastAPI and Starlette. It transparently supports sync or async setters.

Supported Patterns

  • await response.set_header(name, value) for async setters.
  • response.set_header(name, value) for sync setters returning None.
  • await response.headers.set(name, value) for async headers containers.
  • response.headers.set(name, value) for sync headers containers.
  • await response.headers.__setitem__(name, value) for async mappings.
  • response.headers[name] = value for sync mappings.

Parameters

response: ResponseProtocol
Response object implementing either SetHeaderProtocol or HeadersProtocol.

Raises

AttributeError

If the response lacks both .set_header and .headers, or if .headers does not support setting values.

HeaderSetError
If setting an individual header fails.