ietfparse.constants¶
This module contains some useful constant values for using alongside ietfparse.datastructures.ContentType instances or as parameters to the ietfparse.algorithms.select_content_type function. These are cherry-picked from the IANA Media Types registry.
ietfparse.constants
¶
Useful constant values.
Warning
Take care when comparing content type values since equality comparison includes comparing parameter values. The ietfparse.algorithms.select_content_type algorithm should be used to select content type based on the Accept header.
>>> from ietfparse import headers
>>> a = headers.parse_content_type('application/json')
>>> b = headers.parse_content_type('application/json; charset=utf-8')
>>> c = headers.parse_content_type('application/json; charset="UTF-8"')
>>> a == b
False
>>> a == c
False
>>> b == c
True
The last example shows that parameters are normalized when parsing.
Attributes:
| Name | Type | Description |
|---|---|---|
APPLICATION_JSON |
ContentType
|
RFC-8259: The JavaScript Object Notation (JSON) Data Interchange Format |
APPLICATION_OCTET_STREAM |
ContentType
|
Default content type for the Internet as described in [RFC=2045] |
APPLICATION_PROBLEM_JSON |
ContentType
|
HTTP API error document as described by RFC-9457 |
APPLICATION_XML |
ContentType
|
eXtensible Markup Language as described in RFC-7303 |
SMALLEST_QUALITY |
Smallest non-zero quality value |
|
TEXT_HTML |
ContentType
|
|
TEXT_JAVASCRIPT |
ContentType
|
ECMAScript Media Types (RFC-9239) |
TEXT_MARKDOWN |
ContentType
|
Markdown documents (RFC-7763) |
TEXT_PLAIN |
ContentType
|
Simple text content encoded in UTF-8 characters |
APPLICATION_JSON = headers.parse_content_type('application/json')
module-attribute
¶
RFC-8259: The JavaScript Object Notation (JSON) Data Interchange Format
APPLICATION_OCTET_STREAM = headers.parse_content_type('application/octet-stream')
module-attribute
¶
Default content type for the Internet as described in [RFC=2045]
APPLICATION_PROBLEM_JSON = headers.parse_content_type('application/problem+json')
module-attribute
¶
HTTP API error document as described by RFC-9457
APPLICATION_XML = headers.parse_content_type('application/xml')
module-attribute
¶
eXtensible Markup Language as described in RFC-7303
SMALLEST_QUALITY = headers._SMALLEST_QUALITY
module-attribute
¶
Smallest non-zero quality value
TEXT_HTML = headers.parse_content_type('text/html; charset=UTF-8')
module-attribute
¶
TEXT_JAVASCRIPT = headers.parse_content_type('text/javascript; charset=UTF-8')
module-attribute
¶
ECMAScript Media Types (RFC-9239)
TEXT_MARKDOWN = headers.parse_content_type('text/markdown; charset=UTF-8')
module-attribute
¶
Markdown documents (RFC-7763)
RFC-7763 is the formal registration for Markdown formatted content. Daring Fireball: Markdown is the document specification.
options: summary: attributes: true