accept

Accept* headers for Erlang/Elixir

Latest version: 0.3.6 registry icon
Maintenance score
5
Safety score
100
Popularity score
71
Check your open source dependency risks. Get immediate insight about security, stability and licensing risks.
Security
  Vulnerabilities
Version Suggest Low Medium High Critical
0.3.6 0 0 0 0 0
0.3.5 0 0 0 0 0
0.3.4 0 0 0 0 0
0.3.3 0 0 0 0 0
0.3.1 0 0 0 0 0
0.3.0 0 0 0 0 0
0.2.1 0 0 0 0 0
0.2.0 0 0 0 0 0
0.1.0 0 0 0 0 0

Stability
Latest release:

0.3.6 - This version may not be safe as it has not been updated for a long time. Find out if your coding project uses this component and get notified of any reported security vulnerabilities with Meterian-X Open Source Security Platform

Licensing

Maintain your licence declarations and avoid unwanted licences to protect your IP the way you intended.

MIT   -   MIT License

Not a wildcard

Not proprietary

OSI Compliant



Accept header(s) for Erlang/Elixir

Hex.pm Hex.pm Hex Docs GitHub Actions Codecov

TOC

Headers

Accept

RFC

Parsing

1> accept_header:parse("text/*;q=0.3, text/html;q=0.7, text/html;level=1,"
                       "text/html;level=2;q=0.4, */*;q=0.5").
[{media_range,"text","*",0.3,[]},
 {media_range,"text","html",0.7,[]},
 {media_range,"text","html",1,[{"level","1"}]},
 {media_range,"text","html",0.4,[{"level","2"}]},
 {media_range,"*","*",0.5,[]}]

Content Negotiation

2> accept_header:negotiate("text/*;q=0.3, text/html;q=0.7, text/html;level=1,"
                           "text/html;level=2;q=0.4, */*;q=0.5",
                           ["text/html;level=2", "text/html;level-3"]).
"text/html;level-3"

"text/html;level-3" returned because "text/html;level=2" matches to text/html;level=2;q=0.4 with score 0.4 and most specific match for "text/html;level-3" is text/html;q=0.7 with score 0.7.

3> accept_header:negotiate("application/xml,application/xhtml+xml,"
3>                         "text/html;q=0.9,text/plain;q=0.8,image/png,image/*;q=0.9,*/*;q=0.5",
3>                         ["text/n3",
3>                          "application/rdf+xml"]).
"text/n3"

Negotiate preserves user-defined order for equally scored alternatives.

Accept-Encoding

RFC

Parsing

1> accept_encoding_header:parse("gzip;q=1.0, identity; q=0.5, *;q=0").
[{content_coding,"gzip",1.0,[]},
 {content_coding,"identity",0.5,[]},
 {content_coding,"*",0,[]}]

Content Negotiation

1> accept_encoding_header:negotiate("compress, gzip",
1>                                  ["identity", "compress"]).
"compress"

2> accept_encoding_header:negotiate("gzip;q=1.0, identity; q=0.5, *;q=0",
2>                                  ["identity", "sdc", "gzip", "compress"]).
"gzip"

3> accept_encoding_header:negotiate("compress, gzip, *;q=0",
3>                                  ["qwe"]).
undefined

Negotiate preserves user-defined order for equally scored alternatives.