Description
Supplies response construction and cookie helpers above Exchange.
Add_Header
procedure Add_Header
(Item : in out Builder;
Name : String;
Value : String)
Append one validated response header.
Parameters
- Item
Response builder
- Name
Header name
- Value
Header value
Builder
type Builder is tagged private;
Mutable response description that does not borrow an Exchange until Send. It is suitable for nontrivial fixed responses.
Cookie_Options
type Cookie_Options is record
Secure : Boolean := True;
HTTP_Only : Boolean := True;
SameSite : SameSite_Mode := SameSite_Lax;
Path : Ada.Strings.Unbounded.Unbounded_String;
Domain : Ada.Strings.Unbounded.Unbounded_String;
Has_Max_Age : Boolean := False;
Max_Age : Integer := 0;
Expires : Ada.Strings.Unbounded.Unbounded_String;
end record;
Cookie attributes. Expires is an RFC-compatible HTTP date supplied by the application. Has_Max_Age distinguishes omission from zero deletion.
Record fields
- Secure
Emit Secure
- HTTP_Only
Emit HttpOnly
- SameSite
SameSite policy
- Path
Cookie path or empty
- Domain
Cookie domain or empty
- Has_Max_Age
Whether Max-Age is emitted
- Max_Age
Max-Age seconds
- Expires
Optional HTTP date
Initialize
procedure Initialize
(Item : in out Builder;
Status : Positive;
Content_Type : String := "")
Reset a builder to one status and media type.
Parameters
- Item
Response builder
- Status
HTTP status
- Content_Type
Media type or empty
SameSite_Mode
type SameSite_Mode is
(SameSite_Unspecified, SameSite_Lax, SameSite_Strict, SameSite_None);
SameSite cookie policy.
Enumeration literals
- SameSite_Unspecified
Omit SameSite
- SameSite_Lax
Emit SameSite=Lax
- SameSite_Strict
Emit SameSite=Strict
- SameSite_None
Emit SameSite=None and require Secure
Send
procedure Send
(Item : Builder;
X : in out Applications.Exchange;
Close : Boolean := False)
Send the described response and consume no ownership from X.
Parameters
- Item
Response builder
- X
Request exchange
- Close
Force connection close
Set_Cookie
procedure Set_Cookie
(X : in out Applications.Exchange;
Name : String;
Value : String;
Options : Cookie_Options := (others => <>))
Append one validated Set-Cookie field before response start.
Parameters
- X
Request exchange
- Name
Cookie name
- Value
Cookie value
- Options
Cookie attributes
Set_Payload
procedure Set_Payload (Item : in out Builder; Value : String)
Replace the fixed response payload.
Parameters
- Item
Response builder
- Value
Payload bytes