Safe Haskell | None |
---|---|
Language | Haskell2010 |
Defines the types and kinds for working with type and value level headers.
In particular, this module exports a datatype, HeaderName
which is
meant to be used with DataKinds
providing one type, e.g. 'Accept
for
every common header name (and an override one CustomHeader
). It also
exports Sing
values for each HeaderName
-kinded type each merely
being the name of that type prepended with S
.
Finally, it exports a set of type synonms for each HeaderName
-kinded
type so that they can be referenced without the quote prefix '
.
- data SomeHeaderName where
- SomeHeaderName :: forall h. Sing h -> SomeHeaderName
- headerName :: forall s h. IsString s => Sing h -> s
- parseHeaderName :: CI Text -> SomeHeaderName
- data HeaderName
- = CustomHeader Symbol
- | CacheControl
- | Connection
- | ContentLength
- | ContentType
- | Date
- | Pragma
- | Upgrade
- | Via
- | Warning
- | Accept
- | AcceptCharset
- | AcceptEncoding
- | AcceptLanguage
- | AccessControlRequestMethod
- | AccessControlRequestHeaders
- | Authorization
- | Cookie
- | Expect
- | From
- | Host
- | IfMatch
- | IfModifiedSince
- | IfNoneMatch
- | IfRange
- | IfUnmodifiedSince
- | MaxForwards
- | Origin
- | ProxyAuthorization
- | Range
- | Referer
- | TE
- | UserAgent
- | XForwardedFor
- | XForwardedHost
- | XForwardedProto
- | XCsrfToken
- | AccessControlAllowOrigin
- | AccessControlExposeHeaders
- | AccessControlMaxAge
- | AccessControlAllowCredentials
- | AccessControlAllowMethods
- | AccessControlAllowHeaders
- | AcceptPatch
- | AcceptRanges
- | Age
- | Allow
- | ContentDisposition
- | ContentEncoding
- | ContentLanguage
- | ContentLocation
- | ContentRange
- | ContentSecurityPolicy
- | ETag
- | Expires
- | LastModified
- | Link
- | Location
- | ProxyAuthenticate
- | PublicKeyPins
- | RetryAfter
- | SetCookie
- | StrictTransportSecurity
- | Trailer
- | TransferEncoding
- | Vary
- | WWWAuthenticate
- data family Sing a
- type CustomHeader s = CustomHeader s
- type Accept = Accept
- type AcceptCharset = AcceptCharset
- type AcceptEncoding = AcceptEncoding
- type AcceptLanguage = AcceptLanguage
- type AcceptPatch = AcceptPatch
- type AcceptRanges = AcceptRanges
- type AccessControlAllowCredentials = AccessControlAllowCredentials
- type AccessControlAllowHeaders = AccessControlAllowHeaders
- type AccessControlAllowMethods = AccessControlAllowMethods
- type AccessControlAllowOrigin = AccessControlAllowOrigin
- type AccessControlExposeHeaders = AccessControlExposeHeaders
- type AccessControlMaxAge = AccessControlMaxAge
- type AccessControlRequestHeaders = AccessControlRequestHeaders
- type AccessControlRequestMethod = AccessControlRequestMethod
- type Age = Age
- type Allow = Allow
- type Authorization = Authorization
- type CacheControl = CacheControl
- type Connection = Connection
- type ContentDisposition = ContentDisposition
- type ContentEncoding = ContentEncoding
- type ContentLanguage = ContentLanguage
- type ContentLength = ContentLength
- type ContentLocation = ContentLocation
- type ContentRange = ContentRange
- type ContentSecurityPolicy = ContentSecurityPolicy
- type ContentType = ContentType
- type Cookie = Cookie
- type Date = Date
- type ETag = ETag
- type Expect = Expect
- type Expires = Expires
- type From = From
- type Host = Host
- type IfMatch = IfMatch
- type IfModifiedSince = IfModifiedSince
- type IfNoneMatch = IfNoneMatch
- type IfRange = IfRange
- type IfUnmodifiedSince = IfUnmodifiedSince
- type LastModified = LastModified
- type Link = Link
- type Location = Location
- type MaxForwards = MaxForwards
- type Origin = Origin
- type Pragma = Pragma
- type ProxyAuthenticate = ProxyAuthenticate
- type ProxyAuthorization = ProxyAuthorization
- type PublicKeyPins = PublicKeyPins
- type Range = Range
- type Referer = Referer
- type RetryAfter = RetryAfter
- type SetCookie = SetCookie
- type StrictTransportSecurity = StrictTransportSecurity
- type TE = TE
- type Trailer = Trailer
- type TransferEncoding = TransferEncoding
- type Upgrade = Upgrade
- type UserAgent = UserAgent
- type Vary = Vary
- type Via = Via
- type WWWAuthenticate = WWWAuthenticate
- type Warning = Warning
- type XCsrfToken = XCsrfToken
- type XForwardedFor = XForwardedFor
- type XForwardedHost = XForwardedHost
- type XForwardedProto = XForwardedProto
Functions and types for working with HeaderName
Sing
s
data SomeHeaderName where Source
It's difficult to get ahold of values of HeaderName
directly since
they may contain Symbol
values which do not exist. Instead, we can get
almost the same effect through an existential which holds a singleton at
the HeaderName
kind
Note that while the Haddocks show this as taking any Sing
type it is
actually constrained only to have Sing
s of kind HeaderName
.
SomeHeaderName :: forall h. Sing h -> SomeHeaderName |
Eq SomeHeaderName Source | Equality is slightly strange for |
Ord SomeHeaderName Source | |
Show SomeHeaderName Source | |
IsString SomeHeaderName Source | |
HeaderEncode AccessControlExposeHeaders [SomeHeaderName] Source | |
HeaderEncode AccessControlExposeHeaders (Set SomeHeaderName) Source | |
HeaderEncode AccessControlAllowHeaders [SomeHeaderName] Source | |
HeaderEncode AccessControlAllowHeaders (Set SomeHeaderName) Source |
headerName :: forall s h. IsString s => Sing h -> s Source
Extract a string-like representation of a HeaderName
Sing
.
parseHeaderName :: CI Text -> SomeHeaderName Source
Construct a HeaderType
Sing
from a string representation. This
will try to use a standard header type if possible or will default to
CustomHeader
.
The HeaderName
type/kind
data HeaderName Source
A data type representing names describing headers in an HTTP request
or response. Much more importantly, with DataKinds
enabled this
becomes a kind describing types, one for each such header name.
It's worth noting that values of this type can be had, but one branch,
CustomHeader
will not work since it requires Symbol
values which
cannot be had. For this reason prefer using values of SomeHeaderName
instead of values of HeaderName
directly.
CustomHeader Symbol | Inject an arbitatry symbol in as a |
CacheControl | Used to specify directives that must be obeyed by all caching mechanisms along the request-response chain. Tells all caching mechanisms from server to client whether they may cache this object. It is measured in seconds Cache-Control: no-cache |
Connection | Control options for the current connection and list of hop-by-hop request fields Connection: keep-alive Connection: Upgrade |
ContentLength | The length of the request body in octets (8-bit bytes) Content-Length: 348 |
ContentType | The MIME type of the body of the request (used with POST and PUT requests) Content-Type: application/x-www-form-urlencoded |
Date | The date and time that the message was sent (in HTTP-date format as defined by RFC 7231 Date/Time Formats) Date: Tue, 15 Nov 1994 08:12:31 GMT |
Pragma | Implementation-specific fields that may have various effects anywhere along the request-response chain. Pragma: no-cache |
Upgrade | Ask the server to upgrade to another protocol. Upgrade: HTTP2.0, SHTTP1.3, IRC6.9, RTAx11 |
Via | Informs the server of proxies through which the request was sent. Via: 1.0 fred, 1.1 example.com (Apache/1.1) |
Warning | A general warning about possible problems with the entity body. Warning: 199 Miscellaneous warning |
Accept | Content-Types that are acceptable for the response. Accept: text/plain |
AcceptCharset | Character sets that are acceptable Accept-Charset: utf-8 |
AcceptEncoding | List of acceptable encodings. Accept-Encoding: gzip, deflate |
AcceptLanguage | List of acceptable human languages for response. Accept-Language: en-US |
AccessControlRequestMethod | Used when issuing a preflight request to let the server know what HTTP method will be used when the actual request is made. Access-Control-Request-Method: POST |
AccessControlRequestHeaders | Used when issuing a preflight request to let the server know what HTTP headers will be used when the actual request is made. Access-Control-Request-Headers: X-PINGOTHER |
Authorization | Authentication credentials for HTTP authentication Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ== |
Cookie | An HTTP cookie previously sent by the server with Set-Cookie (below) Cookie: $Version=1; Skin=new; |
Expect | Indicates that particular server behaviors are required by the client Expect: 100-continue |
From | The email address of the user making the request From: user@example.com |
Host | The domain name of the server (for virtual hosting), and the TCP port number on which the server is listening. The port number may be omitted if the port is the standard port for the service requested. Host: en.wikipedia.org:80 Host: en.wikipedia.org |
IfMatch | Only perform the action if the client supplied entity matches the same entity on the server. This is mainly for methods like PUT to only update a resource if it has not been modified since the user last updated it. If-Match: "737060cd8c284d8af7ad3082f209582d" |
IfModifiedSince | Allows a 304 Not Modified to be returned if content is unchanged If-Modified-Since: Sat, 29 Oct 1994 19:43:31 GMT |
IfNoneMatch | Allows a 304 Not Modified to be returned if content is unchanged, see HTTP ETag If-None-Match: "737060cd8c284d8af7ad3082f209582d" |
IfRange | If the entity is unchanged, send me the part(s) that I am missing; otherwise, send me the entire new entity If-Range: "737060cd8c284d8af7ad3082f209582d" |
IfUnmodifiedSince | Only send the response if the entity has not been modified since a specific time. If-Unmodified-Since: Sat, 29 Oct 1994 19:43:31 GMT |
MaxForwards | Limit the number of times the message can be forwarded through proxies or gateways. Max-Forwards: 10 |
Origin | Initiates a request for cross-origin resource sharing (asks server for an 'Access-Control-Allow-Origin' response field). |
ProxyAuthorization | Authorization credentials for connecting to a proxy. Proxy-Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ== |
Range | Request only part of an entity. Bytes are numbered from 0. Range: bytes=500-999 |
Referer | This is the address of the previous web page from which a link to the currently requested page was followed. (The word “referrer” has been misspelled in the RFC as well as in most implementations to the point that it has become standard usage and is considered correct terminology) |
TE | The transfer encodings the user agent is willing to accept: the same values as for the response header field Transfer-Encoding can be used, plus the "trailers" value (related to the "chunked" transfer method) to notify the server it expects to receive additional fields in the trailer after the last, zero-sized, chunk. TE: trailers, deflate |
UserAgent | The user agent string of the user agent User-Agent: Mozilla5.0 (X11; Linux x86_64; rv:12.0) Gecko20100101 Firefox/21.0 |
XForwardedFor | A de facto standard for identifying the originating IP address of a client connecting to a web server through an HTTP proxy or load balancer X-Forwarded-For: client1, proxy1, proxy2 X-Forwarded-For: 129.78.138.66, 129.78.64.103 |
XForwardedHost | A de facto standard for identifying the original host requested by the client in the Host HTTP request header, since the host name and/or port of the reverse proxy (load balancer) may differ from the origin server handling the request. X-Forwarded-Host: en.wikipedia.org:80 X-Forwarded-Host: en.wikipedia.org |
XForwardedProto | A de facto standard for identifying the originating protocol of an HTTP request, since a reverse proxy (or a load balancer) may communicate with a web server using HTTP even if the request to the reverse proxy is HTTPS. |
XCsrfToken | Used to prevent cross-site request forgery. X-Csrf-Token: i8XNjC4b8KVok4uw5RftR38Wgp2BFwql |
AccessControlAllowOrigin | When responding to a CORS request this lists either
an origin or Access-Control-Allow-Origin: * Access-Control-Allow-Origin: http://foo.example Access-Control-Allow-Origin: https://foo.example |
AccessControlExposeHeaders | This header lets a server whitelist headers that browsers are allowed to access. Access-Control-Expose-Headers: X-My-Custom-Header, X-Another-Custom-Header |
AccessControlMaxAge | This header indicates how long the results of a preflight request can be cached. Access-Control-Max-Age: delta-seconds |
AccessControlAllowCredentials | Indicates whether or not the response to the request can be exposed when the credentials flag is true. When used as part of a response to a preflight request, this indicates whether or not the actual request can be made using credentials. Note that simple GET requests are not preflighted, and so if a request is made for a resource with credentials, if this header is not returned with the resource, the response is ignored by the browser and not returned to web content. Access-Control-Allow-Credentials: true | false |
AccessControlAllowMethods | Specifies the method or methods allowed when accessing the resource. This is used in response to a preflight request. |
AccessControlAllowHeaders | Used in response to a preflight request to indicate which HTTP headers can be used when making the actual request. |
AcceptPatch | Specifies which patch document formats this server supports Accept-Patch: text/example;charset=utf-8 |
AcceptRanges | What partial content range types this server supports via byte serving Accept-Ranges: bytes |
Age | The age the object has been in a proxy cache in seconds Age: 12 |
Allow | Valid actions for a specified resource. To be used for a 405 Method not allowed Allow: GET, HEAD |
ContentDisposition | An opportunity to raise a "File Download" dialogue box for a known MIME type with binary format or suggest a filename for dynamic content. Quotes are necessary with special characters. Content-Disposition: attachment; filename="fname.ext" |
ContentEncoding | The type of encoding used on the data. Content-Encoding: gzip |
ContentLanguage | The natural language or languages of the intended audience for the enclosed content Content-Language: da |
ContentLocation | An alternate location for the returned data Content-Location: /index.htm |
ContentRange | Where in a full body message this partial message belongs Content-Range: bytes 21010-47021/47022 |
ContentSecurityPolicy | Content Security Policy definition. Content-Security-Policy: default-src |
ETag | An identifier for a specific version of a resource, often a message digest ETag: "737060cd8c284d8af7ad3082f209582d" |
Expires | Gives the date/time after which the response is considered stale (in HTTP-date format as defined by RFC 7231) Expires: Thu, 01 Dec 1994 16:00:00 GMT |
LastModified | The last modified date for the requested object (in HTTP-date format as defined by RFC 7231) Last-Modified: Tue, 15 Nov 1994 12:45:26 GMT |
Link | Used to express a typed relationship with another resource, where the relation type is defined by RFC 5988 Link: /feed; rel="alternate" |
Location | Used in redirection, or when a new resource has been created. Location: http://www.w3.org/pub/WWW/People.html |
ProxyAuthenticate | Request authentication to access the proxy. Proxy-Authenticate: Basic |
PublicKeyPins | HTTP Public Key Pinning, announces hash of website's authentic TLS certificate Public-Key-Pins: max-age=2592000; pin-sha256="E9CZ9INDbd+2eRQozYqqbQ2yXLVKB9+xcprMF+44U1g="; |
RetryAfter | If an entity is temporarily unavailable, this instructs the client to try again later. Value could be a specified period of time (in seconds) or a HTTP-date. Retry-After: 120 Retry-After: Fri, 07 Nov 2014 23:59:59 GMT |
SetCookie | An HTTP cookie Set-Cookie: UserID=JohnDoe; Max-Age=3600; Version=1 |
StrictTransportSecurity | A HSTS Policy informing the HTTP client how long to cache the HTTPS only policy and whether this applies to subdomains. Strict-Transport-Security: max-age=16070400; includeSubDomains |
Trailer | The Trailer general field value indicates that the given set of header fields is present in the trailer of a message encoded with chunked transfer coding. Trailer: Max-Forwards |
TransferEncoding | The form of encoding used to safely transfer the entity to the user. Currently defined methods are: chunked, compress, deflate, gzip, identity. Transfer-Encoding: chunked |
Vary | Tells downstream proxies how to match future request headers to decide whether the cached response can be used rather than requesting a fresh one from the origin server. Vary: * Vary: Accept-Language |
WWWAuthenticate | Indicates the authentication scheme that should be used to access the requested entity. WWW-Authenticate: Basic |
data family Sing a
The singleton kind-indexed data family.
Type synonyms for more convenient use of HeaderName
s
type CustomHeader s = CustomHeader s Source
type AcceptCharset = AcceptCharset Source
type AcceptEncoding = AcceptEncoding Source
type AcceptLanguage = AcceptLanguage Source
type AcceptPatch = AcceptPatch Source
type AcceptRanges = AcceptRanges Source
type Authorization = Authorization Source
type CacheControl = CacheControl Source
type Connection = Connection Source
type ContentEncoding = ContentEncoding Source
type ContentLanguage = ContentLanguage Source
type ContentLength = ContentLength Source
type ContentLocation = ContentLocation Source
type ContentRange = ContentRange Source
type ContentType = ContentType Source
type IfModifiedSince = IfModifiedSince Source
type IfNoneMatch = IfNoneMatch Source
type LastModified = LastModified Source
type MaxForwards = MaxForwards Source
type PublicKeyPins = PublicKeyPins Source
type RetryAfter = RetryAfter Source
type WWWAuthenticate = WWWAuthenticate Source
type XCsrfToken = XCsrfToken Source
type XForwardedFor = XForwardedFor Source
type XForwardedHost = XForwardedHost Source
type XForwardedProto = XForwardedProto Source