std.net.http.Header
type pub inline enum HeaderAn HTTP header.
A Header represents either a standard header or a custom header. If the
header is a standard header it's backed by an Int specific to the header.
These values are defined in std.net.http.header (e.g.
std.net.http.header.CONTENT_TYPE).
Header doesn't use a dedicated constructor for each standard header for the
following reasons:
- The list of standard headers is quite large (64+), affecting the size of generated code
- Using an
Intvalue for standard headers makes it easier to update the code when a new header is added - Pattern matching against header names is rare, instead they're almost
always just used as the keys for a
Map
Constructors
Other
Other(String)A non-standard (i.e. custom) header.
Standard
Standard(Int)A standard header such as Content-Type or Host.
Static methods
accept
Show source codeHide source code
fn pub inline static accept -> Header {
Header.Standard(ACCEPT)
}fn pub inline static accept -> HeaderReturns the Accept header.
Examples
import std.net.http (Header)
Header.accept # => Header.Standard(0)
accept_charset
Show source codeHide source code
fn pub inline static accept_charset -> Header {
Header.Standard(ACCEPT_CHARSET)
}fn pub inline static accept_charset -> HeaderReturns the Accept-Charset header.
Examples
import std.net.http (Header)
Header.accept_charset # => Header.Standard(1)
accept_encoding
Show source codeHide source code
fn pub inline static accept_encoding -> Header {
Header.Standard(ACCEPT_ENCODING)
}fn pub inline static accept_encoding -> HeaderReturns the Accept-Encoding header.
Examples
import std.net.http (Header)
Header.accept_encoding # => Header.Standard(2)
accept_language
Show source codeHide source code
fn pub inline static accept_language -> Header {
Header.Standard(ACCEPT_LANGUAGE)
}fn pub inline static accept_language -> HeaderReturns the Accept-Language header.
Examples
import std.net.http (Header)
Header.accept_language # => Header.Standard(3)
accept_ranges
Show source codeHide source code
fn pub inline static accept_ranges -> Header {
Header.Standard(ACCEPT_RANGES)
}fn pub inline static accept_ranges -> HeaderReturns the Accept-Ranges header.
Examples
import std.net.http (Header)
Header.accept_ranges # => Header.Standard(4)
access_control_allow_credentials
Show source codeHide source code
fn pub inline static access_control_allow_credentials -> Header {
Header.Standard(ACCESS_CONTROL_ALLOW_CREDENTIALS)
}fn pub inline static access_control_allow_credentials -> HeaderReturns the Access-Control-Allow-Credentials header.
Examples
import std.net.http (Header)
Header.access_control_allow_credentials # => Header.Standard(5)
access_control_allow_headers
Show source codeHide source code
fn pub inline static access_control_allow_headers -> Header {
Header.Standard(ACCESS_CONTROL_ALLOW_HEADERS)
}fn pub inline static access_control_allow_headers -> HeaderReturns the Access-Control-Allow-Headers header.
Examples
import std.net.http (Header)
Header.access_control_allow_headers # => Header.Standard(6)
access_control_allow_methods
Show source codeHide source code
fn pub inline static access_control_allow_methods -> Header {
Header.Standard(ACCESS_CONTROL_ALLOW_METHODS)
}fn pub inline static access_control_allow_methods -> HeaderReturns the Access-Control-Allow-Methods header.
Examples
import std.net.http (Header)
Header.access_control_allow_methods # => Header.Standard(7)
access_control_allow_origin
Show source codeHide source code
fn pub inline static access_control_allow_origin -> Header {
Header.Standard(ACCESS_CONTROL_ALLOW_ORIGIN)
}fn pub inline static access_control_allow_origin -> HeaderReturns the Access-Control-Allow-Origin header.
Examples
import std.net.http (Header)
Header.access_control_allow_origin # => Header.Standard(8)
access_control_max_age
Show source codeHide source code
fn pub inline static access_control_max_age -> Header {
Header.Standard(ACCESS_CONTROL_MAX_AGE)
}fn pub inline static access_control_max_age -> HeaderReturns the Access-Control-Max-Age header.
Examples
import std.net.http (Header)
Header.access_control_max_age # => Header.Standard(9)
access_control_method
Show source codeHide source code
fn pub inline static access_control_method -> Header {
Header.Standard(ACCESS_CONTROL_METHOD)
}fn pub inline static access_control_method -> HeaderReturns the Access-Control-Method header.
Examples
import std.net.http (Header)
Header.access_control_method # => Header.Standard(10)
access_control_request_headers
Show source codeHide source code
fn pub inline static access_control_request_headers -> Header {
Header.Standard(ACCESS_CONTROL_REQUEST_HEADERS)
}fn pub inline static access_control_request_headers -> HeaderReturns the Access-Control-Request-Headers header.
Examples
import std.net.http (Header)
Header.access_control_request_headers # => Header.Standard(13)
access_control_request_method
Show source codeHide source code
fn pub inline static access_control_request_method -> Header {
Header.Standard(ACCESS_CONTROL_REQUEST_METHOD)
}fn pub inline static access_control_request_method -> HeaderReturns the Access-Control-Request-Method header.
Examples
import std.net.http (Header)
Header.access_control_request_method # => Header.Standard(11)
access_control_request_methods
Show source codeHide source code
fn pub inline static access_control_request_methods -> Header {
Header.Standard(ACCESS_CONTROL_REQUEST_METHODS)
}fn pub inline static access_control_request_methods -> HeaderReturns the Access-Control-Request-Methods header.
Examples
import std.net.http (Header)
Header.access_control_request_methods # => Header.Standard(12)
age
Show source codeHide source code
fn pub inline static age -> Header {
Header.Standard(AGE)
}fn pub inline static age -> HeaderReturns the Age header.
Examples
import std.net.http (Header)
Header.age # => Header.Standard(14)
allow
Show source codeHide source code
fn pub inline static allow -> Header {
Header.Standard(ALLOW)
}fn pub inline static allow -> HeaderReturns the Allow header.
Examples
import std.net.http (Header)
Header.allow # => Header.Standard(15)
alt_svc
Show source codeHide source code
fn pub inline static alt_svc -> Header {
Header.Standard(ALT_SVC)
}fn pub inline static alt_svc -> HeaderReturns the Alt-Svc header.
Examples
import std.net.http (Header)
Header.alt_svc # => Header.Standard(16)
authorization
Show source codeHide source code
fn pub inline static authorization -> Header {
Header.Standard(AUTHORIZATION)
}fn pub inline static authorization -> HeaderReturns the Authorization header.
Examples
import std.net.http (Header)
Header.authorization # => Header.Standard(17)
cache_control
Show source codeHide source code
fn pub inline static cache_control -> Header {
Header.Standard(CACHE_CONTROL)
}fn pub inline static cache_control -> HeaderReturns the Cache-Control header.
Examples
import std.net.http (Header)
Header.cache_control # => Header.Standard(18)
connection
Show source codeHide source code
fn pub inline static connection -> Header {
Header.Standard(CONNECTION)
}fn pub inline static connection -> HeaderReturns the Connection header.
Examples
import std.net.http (Header)
Header.connection # => Header.Standard(19)
content_disposition
Show source codeHide source code
fn pub inline static content_disposition -> Header {
Header.Standard(CONTENT_DISPOSITION)
}fn pub inline static content_disposition -> HeaderReturns the Content-Disposition header.
Examples
import std.net.http (Header)
Header.content_disposition # => Header.Standard(20)
content_encoding
Show source codeHide source code
fn pub inline static content_encoding -> Header {
Header.Standard(CONTENT_ENCODING)
}fn pub inline static content_encoding -> HeaderReturns the Content-Encoding header.
Examples
import std.net.http (Header)
Header.content_encoding # => Header.Standard(21)
content_language
Show source codeHide source code
fn pub inline static content_language -> Header {
Header.Standard(CONTENT_LANGUAGE)
}fn pub inline static content_language -> HeaderReturns the Content-Language header.
Examples
import std.net.http (Header)
Header.content_language # => Header.Standard(22)
content_length
Show source codeHide source code
fn pub inline static content_length -> Header {
Header.Standard(CONTENT_LENGTH)
}fn pub inline static content_length -> HeaderReturns the Content-Length header.
Examples
import std.net.http (Header)
Header.content_length # => Header.Standard(23)
content_location
Show source codeHide source code
fn pub inline static content_location -> Header {
Header.Standard(CONTENT_LOCATION)
}fn pub inline static content_location -> HeaderReturns the Content-Location header.
Examples
import std.net.http (Header)
Header.content_location # => Header.Standard(24)
content_range
Show source codeHide source code
fn pub inline static content_range -> Header {
Header.Standard(CONTENT_RANGE)
}fn pub inline static content_range -> HeaderReturns the Content-Range header.
Examples
import std.net.http (Header)
Header.content_range # => Header.Standard(25)
content_type
Show source codeHide source code
fn pub inline static content_type -> Header {
Header.Standard(CONTENT_TYPE)
}fn pub inline static content_type -> HeaderReturns the Content-Type header.
Examples
import std.net.http (Header)
Header.content_type # => Header.Standard(26)
cookie
Show source codeHide source code
fn pub inline static cookie -> Header {
Header.Standard(COOKIE)
}fn pub inline static cookie -> HeaderReturns the Cookie header.
Examples
import std.net.http (Header)
Header.cookie # => Header.Standard(27)
date
Show source codeHide source code
fn pub inline static date -> Header {
Header.Standard(DATE)
}fn pub inline static date -> HeaderReturns the Date header.
Examples
import std.net.http (Header)
Header.date # => Header.Standard(28)
etag
Show source codeHide source code
fn pub inline static etag -> Header {
Header.Standard(ETAG)
}fn pub inline static etag -> HeaderReturns the Etag header.
Examples
import std.net.http (Header)
Header.etag # => Header.Standard(29)
expect
Show source codeHide source code
fn pub inline static expect -> Header {
Header.Standard(EXPECT)
}fn pub inline static expect -> HeaderReturns the Expect header.
Examples
import std.net.http (Header)
Header.expect # => Header.Standard(30)
expires
Show source codeHide source code
fn pub inline static expires -> Header {
Header.Standard(EXPIRES)
}fn pub inline static expires -> HeaderReturns the Expires header.
Examples
import std.net.http (Header)
Header.expires # => Header.Standard(31)
from
Show source codeHide source code
fn pub inline static from -> Header {
Header.Standard(FROM)
}fn pub inline static from -> HeaderReturns the From header.
Examples
import std.net.http (Header)
Header.from # => Header.Standard(32)
host
Show source codeHide source code
fn pub inline static host -> Header {
Header.Standard(HOST)
}fn pub inline static host -> HeaderReturns the Host header.
Examples
import std.net.http (Header)
Header.host # => Header.Standard(33)
if_match
Show source codeHide source code
fn pub inline static if_match -> Header {
Header.Standard(IF_MATCH)
}fn pub inline static if_match -> HeaderReturns the If-Match header.
Examples
import std.net.http (Header)
Header.if_match # => Header.Standard(34)
if_modified_since
Show source codeHide source code
fn pub inline static if_modified_since -> Header {
Header.Standard(IF_MODIFIED_SINCE)
}fn pub inline static if_modified_since -> HeaderReturns the If-Modified-Since header.
Examples
import std.net.http (Header)
Header.if_modified_since # => Header.Standard(35)
if_none_match
Show source codeHide source code
fn pub inline static if_none_match -> Header {
Header.Standard(IF_NONE_MATCH)
}fn pub inline static if_none_match -> HeaderReturns the If-None-Match header.
Examples
import std.net.http (Header)
Header.if_none_match # => Header.Standard(36)
if_range
Show source codeHide source code
fn pub inline static if_range -> Header {
Header.Standard(IF_RANGE)
}fn pub inline static if_range -> HeaderReturns the If-Range header.
Examples
import std.net.http (Header)
Header.if_range # => Header.Standard(37)
if_unmodified_since
Show source codeHide source code
fn pub inline static if_unmodified_since -> Header {
Header.Standard(IF_UNMODIFIED_SINCE)
}fn pub inline static if_unmodified_since -> HeaderReturns the If-Unmodified-Since header.
Examples
import std.net.http (Header)
Header.if_unmodified_since # => Header.Standard(38)
keep_alive
Show source codeHide source code
fn pub inline static keep_alive -> Header {
Header.Standard(KEEP_ALIVE)
}fn pub inline static keep_alive -> HeaderReturns the Keep-Alive header.
Examples
import std.net.http (Header)
Header.keep_alive # => Header.Standard(39)
last_modified
Show source codeHide source code
fn pub inline static last_modified -> Header {
Header.Standard(LAST_MODIFIED)
}fn pub inline static last_modified -> HeaderReturns the Last-Modified header.
Examples
import std.net.http (Header)
Header.last_modified # => Header.Standard(40)
link
Show source codeHide source code
fn pub inline static link -> Header {
Header.Standard(LINK)
}fn pub inline static link -> HeaderReturns the Link header.
Examples
import std.net.http (Header)
Header.link # => Header.Standard(41)
location
Show source codeHide source code
fn pub inline static location -> Header {
Header.Standard(LOCATION)
}fn pub inline static location -> HeaderReturns the Location header.
Examples
import std.net.http (Header)
Header.location # => Header.Standard(42)
max_forwards
Show source codeHide source code
fn pub inline static max_forwards -> Header {
Header.Standard(MAX_FORWARDS)
}fn pub inline static max_forwards -> HeaderReturns the Max-Forwards header.
Examples
import std.net.http (Header)
Header.max_forwards # => Header.Standard(43)
new
Show source codeHide source code
fn pub static new[B: Bytes + ToString](input: ref B) -> Header {
match header.index_of(input) {
case -1 -> Header.Other(input.to_string)
case n -> Header.Standard(n)
}
}fn pub static new[B: Bytes + ToString](input: ref B) -> HeaderParses a Header from a sequence of bytes.
This method expects that the input is already in lowercase. If this isn't the case, the input is treated as a non-standard header.
For non-standard headers the input is converted to a String and returned
as Header.Other.
Examples
import std.net.http (Header)
Header.new('content-length') # => Header.content_length
Header.new('example-header') # => Header.Other('example-header')
origin
Show source codeHide source code
fn pub inline static origin -> Header {
Header.Standard(ORIGIN)
}fn pub inline static origin -> HeaderReturns the Origin header.
Examples
import std.net.http (Header)
Header.origin # => Header.Standard(44)
pragma
Show source codeHide source code
fn pub inline static pragma -> Header {
Header.Standard(PRAGMA)
}fn pub inline static pragma -> HeaderReturns the Pragma header.
Examples
import std.net.http (Header)
Header.pragma # => Header.Standard(45)
proxy_authenticate
Show source codeHide source code
fn pub inline static proxy_authenticate -> Header {
Header.Standard(PROXY_AUTHENTICATE)
}fn pub inline static proxy_authenticate -> HeaderReturns the Proxy-Authenticate header.
Examples
import std.net.http (Header)
Header.proxy_authenticate # => Header.Standard(46)
proxy_authorization
Show source codeHide source code
fn pub inline static proxy_authorization -> Header {
Header.Standard(PROXY_AUTHORIZATION)
}fn pub inline static proxy_authorization -> HeaderReturns the Proxy-Authorization header.
Examples
import std.net.http (Header)
Header.proxy_authorization # => Header.Standard(47)
proxy_connection
Show source codeHide source code
fn pub inline static proxy_connection -> Header {
Header.Standard(PROXY_CONNECTION)
}fn pub inline static proxy_connection -> HeaderReturns the Proxy-Connection header.
Examples
import std.net.http (Header)
Header.proxy_connection # => Header.Standard(48)
range
Show source codeHide source code
fn pub inline static range -> Header {
Header.Standard(RANGE)
}fn pub inline static range -> HeaderReturns the Range header.
Examples
import std.net.http (Header)
Header.range # => Header.Standard(49)
referer
Show source codeHide source code
fn pub inline static referer -> Header {
Header.Standard(REFERER)
}fn pub inline static referer -> HeaderReturns the Referer header.
Examples
import std.net.http (Header)
Header.referer # => Header.Standard(50)
retry_after
Show source codeHide source code
fn pub inline static retry_after -> Header {
Header.Standard(RETRY_AFTER)
}fn pub inline static retry_after -> HeaderReturns the Retry-After header.
Examples
import std.net.http (Header)
Header.retry_after # => Header.Standard(51)
sec_fetch_dest
Show source codeHide source code
fn pub inline static sec_fetch_dest -> Header {
Header.Standard(SEC_FETCH_DEST)
}fn pub inline static sec_fetch_dest -> HeaderReturns the Sec-Fetch-Dest header.
Examples
import std.net.http (Header)
Header.sec_fetch_dest # => Header.Standard(66)
sec_fetch_mode
Show source codeHide source code
fn pub inline static sec_fetch_mode -> Header {
Header.Standard(SEC_FETCH_MODE)
}fn pub inline static sec_fetch_mode -> HeaderReturns the Sec-Fetch-Mode header.
Examples
import std.net.http (Header)
Header.sec_fetch_mode # => Header.Standard(64)
sec_fetch_site
Show source codeHide source code
fn pub inline static sec_fetch_site -> Header {
Header.Standard(SEC_FETCH_SITE)
}fn pub inline static sec_fetch_site -> HeaderReturns the Sec-Fetch-Site header.
Examples
import std.net.http (Header)
Header.sec_fetch_site # => Header.Standard(63)
sec_fetch_user
Show source codeHide source code
fn pub inline static sec_fetch_user -> Header {
Header.Standard(SEC_FETCH_USER)
}fn pub inline static sec_fetch_user -> HeaderReturns the Sec-Fetch-User header.
Examples
import std.net.http (Header)
Header.sec_fetch_user # => Header.Standard(65)
sec_websocket_accept
Show source codeHide source code
fn pub inline static sec_websocket_accept -> Header {
Header.Standard(SEC_WEBSOCKET_ACCEPT)
}fn pub inline static sec_websocket_accept -> HeaderReturns the Sec-Websocket-Accept header.
Examples
import std.net.http (Header)
Header.sec_websocket_accept # => Header.Standard(67)
sec_websocket_extensions
Show source codeHide source code
fn pub inline static sec_websocket_extensions -> Header {
Header.Standard(SEC_WEBSOCKET_EXTENSIONS)
}fn pub inline static sec_websocket_extensions -> HeaderReturns the Sec-Websocket-Extensions header.
Examples
import std.net.http (Header)
Header.sec_websocket_extensions # => Header.Standard(68)
sec_websocket_key
Show source codeHide source code
fn pub inline static sec_websocket_key -> Header {
Header.Standard(SEC_WEBSOCKET_KEY)
}fn pub inline static sec_websocket_key -> HeaderReturns the Sec-Websocket-Key header.
Examples
import std.net.http (Header)
Header.sec_websocket_key # => Header.Standard(69)
sec_websocket_protocol
Show source codeHide source code
fn pub inline static sec_websocket_protocol -> Header {
Header.Standard(SEC_WEBSOCKET_PROTOCOL)
}fn pub inline static sec_websocket_protocol -> HeaderReturns the Sec-Websocket-Protocol header.
Examples
import std.net.http (Header)
Header.sec_websocket_protocol # => Header.Standard(70)
sec_websocket_version
Show source codeHide source code
fn pub inline static sec_websocket_version -> Header {
Header.Standard(SEC_WEBSOCKET_VERSION)
}fn pub inline static sec_websocket_version -> HeaderReturns the Sec-Websocket-Version header.
Examples
import std.net.http (Header)
Header.sec_websocket_version # => Header.Standard(71)
server
Show source codeHide source code
fn pub inline static server -> Header {
Header.Standard(SERVER)
}fn pub inline static server -> HeaderReturns the Server header.
Examples
import std.net.http (Header)
Header.server # => Header.Standard(52)
set_cookie
Show source codeHide source code
fn pub inline static set_cookie -> Header {
Header.Standard(SET_COOKIE)
}fn pub inline static set_cookie -> HeaderReturns the Set-Cookie header.
Examples
import std.net.http (Header)
Header.set_cookie # => Header.Standard(53)
strict_transport_security
Show source codeHide source code
fn pub inline static strict_transport_security -> Header {
Header.Standard(STRICT_TRANSPORT_SECURITY)
}fn pub inline static strict_transport_security -> HeaderReturns the Strict-Transport-Security header.
Examples
import std.net.http (Header)
Header.strict_transport_security # => Header.Standard(54)
trailer
Show source codeHide source code
fn pub inline static trailer -> Header {
Header.Standard(TRAILER)
}fn pub inline static trailer -> HeaderReturns the Trailer header.
Examples
import std.net.http (Header)
Header.trailer # => Header.Standard(55)
transfer_encoding
Show source codeHide source code
fn pub inline static transfer_encoding -> Header {
Header.Standard(TRANSFER_ENCODING)
}fn pub inline static transfer_encoding -> HeaderReturns the Transfer-Encoding header.
Examples
import std.net.http (Header)
Header.transfer_encoding # => Header.Standard(56)
upgrade
Show source codeHide source code
fn pub inline static upgrade -> Header {
Header.Standard(UPGRADE)
}fn pub inline static upgrade -> HeaderReturns the Upgrade header.
Examples
import std.net.http (Header)
Header.upgrade # => Header.Standard(57)
upgrade_insecure_requests
Show source codeHide source code
fn pub inline static upgrade_insecure_requests -> Header {
Header.Standard(UPGRADE_INSECURE_REQUESTS)
}fn pub inline static upgrade_insecure_requests -> HeaderReturns the Upgrade-Insecure-Requests header.
Examples
import std.net.http (Header)
Header.upgrade_insecure_requests # => Header.Standard(58)
user_agent
Show source codeHide source code
fn pub inline static user_agent -> Header {
Header.Standard(USER_AGENT)
}fn pub inline static user_agent -> HeaderReturns the User-Agent header.
Examples
import std.net.http (Header)
Header.user_agent # => Header.Standard(59)
vary
Show source codeHide source code
fn pub inline static vary -> Header {
Header.Standard(VARY)
}fn pub inline static vary -> HeaderReturns the Vary header.
Examples
import std.net.http (Header)
Header.vary # => Header.Standard(60)
via
Show source codeHide source code
fn pub inline static via -> Header {
Header.Standard(VIA)
}fn pub inline static via -> HeaderReturns the Via header.
Examples
import std.net.http (Header)
Header.via # => Header.Standard(61)
www_authenticate
Show source codeHide source code
fn pub inline static www_authenticate -> Header {
Header.Standard(WWW_AUTHENTICATE)
}fn pub inline static www_authenticate -> HeaderReturns the Www-Authenticate header.
Examples
import std.net.http (Header)
Header.www_authenticate # => Header.Standard(62)
Instance methods
!=
Show source codeHide source code
fn pub !=(other: ref Self) -> Bool {
!(self == other)
}fn pub !=(other: ref Self) -> BoolReturns true if self and the given object are not equal to each other.
==
Show source codeHide source code
fn pub ==(other: ref Header) -> Bool {
match (self, other) {
case (Standard(a), Standard(b)) -> a == b
case (Other(a), Other(b)) -> a == b
case _ -> false
}
}fn pub ==(other: ref Header) -> BoolReturns true if self and the given object are equal to each other.
This operator is used to perform structural equality. This means two objects residing in different memory locations may be considered equal, provided their structure is equal. For example, two different arrays may be considered to have structural equality if they contain the exact same values.
clone
Show source codeHide source code
fn pub clone -> Self {
match self {
case Standard(v) -> Header.Standard(v)
case Other(v) -> Header.Other(v)
}
}fn pub clone -> HeaderCreates a clone of self.
The returned value is an owned value that is the same type as the receiver
of this method. For example, cloning a ref Array[Int] results in a
Array[Int], not another ref Array[Int].
fmt
Show source codeHide source code
fn pub fmt(formatter: mut Formatter) {
formatter.write(to_string)
}fn pub fmt(formatter: mut Formatter)Formats self in a human-readable format for debugging purposes.
hash
Show source codeHide source code
fn pub hash[H: mut + Hasher](hasher: mut H) {
match self {
case Standard(v) -> v.hash(hasher)
case Other(v) -> v.hash(hasher)
}
}fn pub hash[H: mut + Hasher](hasher: mut H: mut)Writes the hash for self into the given Hasher.
to_string
Show source codeHide source code
fn pub to_string -> String {
match self {
case Standard(v) -> header.name(v)
case Other(v) -> v
}
}fn pub to_string -> StringConverts self to a String.
Implemented traits
Clone
impl Clone for HeaderEqual
impl Equal for HeaderFormat
impl Format for HeaderHash
impl Hash for HeaderToString
impl ToString for Header