A11 (C++ runtime)
Native C++ implementation of the A11 streaming action runtime
Loading...
Searching...
No Matches
server_headers.h File Reference

The response headers every A11 HTTP server sends, in one place. More...

#include <string>
#include <string_view>
#include <absl/status/status.h>
#include "a11/net/http2.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  a11::net::CorsOptions
 Cross-origin policy for an A11 HTTP surface. More...
 
struct  a11::net::ServerHeaderOptions
 The response-header policy of one A11 HTTP surface. More...
 

Namespaces

namespace  a11
 
namespace  a11::net
 

Enumerations

enum class  a11::net::CachePolicy { a11::net::kStream , a11::net::kVolatile , a11::net::kUnset }
 How a response may be cached, which differs by what it is. More...
 

Functions

void a11::net::ApplyServerHeaders (const ServerHeaderOptions &options, CachePolicy cache, HttpHeaders *absl_nonnull headers)
 Adds the headers every response from an A11 server carries.
 
HttpHeaders a11::net::CorsHeaders (const CorsOptions &options)
 The cross-origin headers for options, and nothing else.
 
void a11::net::ApplyCorsHeaders (const CorsOptions &options, HttpHeaders *absl_nonnull headers)
 Adds the cross-origin headers for options to headers.
 
bool a11::net::IsPreflight (const CorsOptions &options, std::string_view method)
 Whether method is a CORS preflight this policy should answer.
 

Variables

constexpr std::string_view a11::net::kServerHeaderValue = "a11"
 Value of the Server header A11's HTTP surfaces send.
 

Detailed Description

The response headers every A11 HTTP server sends, in one place.

Why this exists. The headers a server owes its clients were decided per endpoint: CORS lived on a11::net::HttpSseOptions as four loose strings that only the SSE routes consulted, the WebSocket server's HTTP surface sent none at all, and nothing sent a Server header or told a cache what to do with a reply. None of that is per-endpoint policy – it is what an A11 server is – so it is stated once here and applied by whichever transport holds the port.

Everything here is a hint or a policy, not behaviour: no header changes what a response contains. What they change is whether a browser will read it, and whether an intermediary will cache, buffer or sniff it – and the defaults below are what makes a browser client work without anybody configuring one.