Esempio n. 1
0
from httpolice.parse import (auto, case_sens, fill_names, literal, maybe_str,
                             pivot)
from httpolice.syntax.rfc3986 import host, port, scheme
from httpolice.syntax.rfc7230 import (comma_list, comma_list1, field_name,
                                      method)
from httpolice.syntax.rfc7234 import delta_seconds

# WHATWG actually uses their own definitions for scheme, host, and port,
# but that's a bit too far for HTTPolice, we can live with RFC 3986.
origin = scheme + '://' + host + maybe_str(':' + port) > pivot
origin_or_null = origin | case_sens('null') > pivot
Origin = origin_or_null > pivot

Access_Control_Request_Method = method > pivot
Access_Control_Request_Headers = comma_list1(field_name) > pivot
wildcard = literal('*') > auto
Access_Control_Allow_Origin = origin_or_null | wildcard > pivot
Access_Control_Allow_Credentials = case_sens('true') > pivot
Access_Control_Expose_Headers = comma_list(field_name) > pivot
Access_Control_Max_Age = delta_seconds > pivot
Access_Control_Allow_Methods = comma_list(method) > pivot
Access_Control_Allow_Headers = comma_list(field_name) > pivot

X_Content_Type_Options = literal('nosniff') > pivot

Cross_Origin_Resource_Policy = (case_sens('same-origin')
                                | case_sens('same-site')) > pivot

fill_names(globals(),
           Citation(u'WHATWG Fetch', u'https://fetch.spec.whatwg.org/'))
Esempio n. 2
0
# -*- coding: utf-8; -*-

from httpolice.parse import (fill_names, literal, maybe, pivot, skip, string1,
                             subst)
from httpolice.syntax.common import DIGIT
from httpolice.syntax.rfc7230 import RWS, comma_list

notice_id = int << string1(DIGIT) > pivot
resp = subst(True) << literal('resp') > pivot
HTTPolice_Silence = comma_list(notice_id * maybe(skip(RWS) * resp)) > pivot

fill_names(globals(), citation=None)
Esempio n. 3
0
# We don't need to special-case "UTF-8", simplify.
mime_charsetc = (ALPHA | DIGIT |
                 '!' | '#' | '$' | '%' | '&' | '+' | '-' | '^' | '_' | '`' |
                 '{' | '}' | '~')                                       > auto
mime_charset = string1(mime_charsetc)                                   > auto
charset = CaseInsensitive << mime_charset                               > pivot

pct_encoded = '%' + HEXDIG + HEXDIG                                     > auto
value_chars = pct_decode << (
    force_bytes << string(pct_encoded | attr_char))                     > auto

@can_complain
def _check_ext_value(complain, val):
    if val.charset == u'UTF-8':
        try:
            val.value_bytes.decode(val.charset)
        except UnicodeError as e:
            complain(1254, charset=val.charset, error=e)
    else:
        complain(1253, charset=val.charset)
    return val

ext_value = _check_ext_value << (
    ExtValue << (charset * skip("'") *
                 maybe(language) * skip("'") *
                 value_chars))                                          > pivot


fill_names(globals(), RFC(8187))
Esempio n. 4
0
# -*- coding: utf-8; -*-

from httpolice.citation import RFC
from httpolice.parse import auto, fill_names, many, maybe, pivot, skip, string1
from httpolice.structure import HSTSDirective, Parametrized
from httpolice.syntax.common import DIGIT
from httpolice.syntax.rfc7230 import OWS, quoted_string, token


# This has been slightly adapted to the rules of RFC 7230.
# The ``OWS`` are derived from the "implied ``*LWS``" requirement.

directive_name = HSTSDirective << token                                 > auto
directive_value = token | quoted_string                                 > auto
directive = Parametrized << (
    directive_name * maybe(skip(OWS * '=' * OWS) * directive_value))    > pivot

def _collect_elements(xs):
    return [elem for elem in xs if elem is not None]

Strict_Transport_Security = _collect_elements << (
    maybe(directive) % many(skip(OWS * ';' * OWS) * maybe(directive)))  > pivot

max_age_value = int << string1(DIGIT)                                   > pivot

fill_names(globals(), RFC(6797))
Esempio n. 5
0
           'zh-min-nan'          |
           'zh-xiang')                                                  > auto

grandfathered = irregular | regular                                     > pivot
privateuse = 'x' + string1('-' + string_times(1, 8, alphanum))          > pivot

extlang = (string_times(3, 3, ALPHA) +
           string_times(0, 2, '-' + string_times(3, 3, ALPHA)))         > pivot

language = (string_times(2, 3, ALPHA) + maybe_str('-' + extlang) |
            string_times(4, 4, ALPHA) | string_times(5, 8, ALPHA))      > pivot
script = string_times(4, 4, ALPHA)                                      > pivot
region = string_times(2, 2, ALPHA) | string_times(3, 3, DIGIT)          > pivot
variant = (string_times(5, 8, alphanum) |
           (DIGIT + string_times(3, 3, alphanum)))                      > pivot
extension = (singleton + string1('-' + string_times(2, 8, alphanum)))   > pivot

langtag = (language +
           maybe_str('-' + script) +
           maybe_str('-' + region) +
           string('-' + variant) +
           string('-' + extension) +
           maybe_str('-' + privateuse))                                 > pivot

Language_Tag = (LanguageTag << langtag |
                LanguageTag << privateuse |
                LanguageTag << grandfathered)                           > pivot


fill_names(globals(), RFC(5646))
Esempio n. 6
0
from httpolice.citation import RFC
from httpolice.parse import fill_names, pivot
from httpolice.syntax.rfc7235 import token68


HTTP2_Settings = token68                                                > pivot


fill_names(globals(), RFC(7540))
Esempio n. 7
0
            correct_encoded_id += pct_encode(c, safe='').upper()
    if encoded_id != correct_encoded_id:
        complain(1256, actual=encoded_id, correct=correct_encoded_id)
    return decoded_id

protocol_id = _check_protocol_id << token                               > pivot

@can_complain
def _check_alt_authority(complain, value):
    return parse(value, maybe_str(uri_host) + ':' + port, complain, 1257,
                 authority=value)

alt_authority = _check_alt_authority << quoted_string                   > pivot

alternative = protocol_id * skip('=') * alt_authority                   > pivot
parameter = ((AltSvcParam << token) *
             skip('=') * (token | quoted_string))                       > pivot
alt_value = Parametrized << (
    alternative *
    (MultiDict << many(skip(OWS * ';' * OWS) * parameter)))             > pivot

Alt_Svc = clear | comma_list1(alt_value)                                > pivot

ma = delta_seconds                                                      > pivot
persist = subst(True) << literal('1')                                   > pivot

Alt_Used = uri_host + maybe_str(':' + port)                             > pivot


fill_names(globals(), RFC(7838))
Esempio n. 8
0
# -*- coding: utf-8; -*-

from httpolice.citation import RFC
from httpolice.parse import auto, fill_names, octet, octet_range

ALPHA = octet_range(0x41, 0x5A) | octet_range(0x61, 0x7A) > auto
CHAR = octet_range(0x01, 0x7F) > auto
CTL = octet_range(0x00, 0x1F) | octet(0x7F) > auto
CR = octet(0x0D) > auto
DIGIT = octet_range(0x30, 0x39) > auto
DQUOTE = octet(0x22) > auto
HEXDIG = DIGIT | 'A' | 'B' | 'C' | 'D' | 'E' | 'F' > auto
HTAB = octet(0x09) > auto
LF = octet(0x0A) > auto
SP = octet(0x20) > auto
VCHAR = octet_range(0x21, 0x7E) > auto

CRLF = CR + LF > auto

fill_names(globals(), RFC(5234))
Esempio n. 9
0
# -*- coding: utf-8; -*-

from httpolice.citation import RFC
from httpolice.parse import fill_names, pivot
from httpolice.syntax.rfc7230 import comma_list1
from httpolice.syntax.rfc7231 import media_type


Accept_Patch = comma_list1(media_type)                                  > pivot

fill_names(globals(), RFC(5789))
Esempio n. 10
0
# -*- coding: utf-8; -*-

from httpolice.citation import Citation
from httpolice.parse import fill_names, pivot
from httpolice.syntax.rfc7230 import comma_list
from httpolice.syntax.rfc7231 import media_range


Accept_Post = comma_list(media_range())                                > pivot

fill_names(globals(), Citation(u'W3C Linked Data Platform 1.0',
                               u'https://www.w3.org/TR/2015/REC-ldp-20150226/'))
Esempio n. 11
0
# -*- coding: utf-8; -*-

from httpolice.parse import (
    fill_names,
    literal,
    maybe,
    pivot,
    skip,
    string1,
    subst,
)
from httpolice.syntax.common import DIGIT
from httpolice.syntax.rfc7230 import RWS, comma_list


notice_id = int << string1(DIGIT)                                       > pivot
resp = subst(True) << literal('resp')                                   > pivot
HTTPolice_Silence = comma_list(notice_id * maybe(skip(RWS) * resp))     > pivot


fill_names(globals(), citation=None)
Esempio n. 12
0
        if name == u'rev':
            complain(1226)
    if u'rel' not in seen:
        complain(1309)
    return MultiDict(r)


link_param = ((CaseInsensitive << token) * skip(BWS) * maybe(
    skip(literal('=') * BWS) * (mark(token) | mark(quoted_string)))) > pivot

link_value = Parametrized << (
    skip('<') * URI_Reference * skip('>') *
    (_process_params << many(skip(OWS * ';' * OWS) * link_param))) > pivot

Link = comma_list(link_value) > pivot

anchor = URI_Reference > auto

reg_rel_type = CaseInsensitive << (LOALPHA +
                                   string(LOALPHA | DIGIT | '.' | '-')) > auto
ext_rel_type = URI > auto
relation_type = reg_rel_type | ext_rel_type > pivot
rel = rev = relation_type % many(skip(string1(SP)) * relation_type) > auto

hreflang = Language_Tag > auto

type_ = check_media_type << (
    MediaType << type_name + '/' + subtype_name) > auto

fill_names(globals(), RFC(8288))
Esempio n. 13
0
from httpolice.citation import RFC
from httpolice.parse import auto, fill_names, octet_range
from httpolice.syntax.rfc7230 import quoted_string, token

LOALPHA = octet_range(0x61, 0x7A) > auto

value = token | quoted_string > auto

fill_names(globals(), RFC(2616))
Esempio n. 14
0
port = string(DIGIT)                                                    > pivot
authority = maybe_str(userinfo + '@') + host + maybe_str(':' + port)    > pivot

path_abempty = string('/' + segment)                                    > auto
path_absolute = '/' + maybe_str(segment_nz + string('/' + segment))     > auto
path_noscheme = segment_nz_nc + string('/' + segment)                   > auto
path_rootless = segment_nz + string('/' + segment)                      > auto
path_empty = subst(u'') << empty                                        > auto

hier_part = ('//' + authority + path_abempty |
             path_absolute | path_rootless | path_empty)                > pivot

query = string(pchar | '/' | '?')                                       > pivot
fragment = string(pchar | '/' | '?')                                    > pivot

absolute_URI = scheme + ':' + hier_part + maybe_str('?' + query)        > pivot

relative_part = ('//' + authority + path_abempty |
                 path_absolute | path_noscheme | path_empty)            > pivot

URI = (scheme + ':' + hier_part +
       maybe_str('?' + query) + maybe_str('#' + fragment))              > pivot

relative_ref = (relative_part +
                maybe_str('?' + query) + maybe_str('#' + fragment))     > pivot

URI_reference = URI | relative_ref                                      > pivot


fill_names(globals(), RFC(3986))
Esempio n. 15
0
# We don't need to special-case "UTF-8" and "ISO-8859-1", simplify.
mime_charsetc = (ALPHA | DIGIT |
                 '!' | '#' | '$' | '%' | '&' | '+' | '-' | '^' | '_' | '`' |
                 '{' | '}' | '~')                                       > auto
mime_charset = string1(mime_charsetc)                                   > auto
charset = CaseInsensitive << mime_charset                               > pivot

pct_encoded = '%' + HEXDIG + HEXDIG                                     > auto
value_chars = pct_decode << (
    force_bytes << string(pct_encoded | attr_char))                     > auto

@can_complain
def _check_ext_value(complain, val):
    if val.charset in [u'UTF-8', u'ISO-8859-1']:
        try:
            val.value_bytes.decode(val.charset)
        except UnicodeError as e:
            complain(1254, charset=val.charset, error=e)
    else:
        complain(1253, charset=val.charset)
    return val

ext_value = _check_ext_value << (
    ExtValue << (charset * skip("'") *
                 maybe(language) * skip("'") *
                 value_chars))                                          > pivot


fill_names(globals(), RFC(5987))
Esempio n. 16
0
# -*- coding: utf-8; -*-

from httpolice.citation import RFC
from httpolice.parse import auto, fill_names, pivot, string, string_times
from httpolice.structure import CaseInsensitive
from httpolice.syntax.common import ALPHA, DIGIT

alphanum = ALPHA | DIGIT > auto
language_range = CaseInsensitive << (string_times(
    1, 8, ALPHA) + string('-' + string_times(1, 8, alphanum)) | '*') > pivot

fill_names(globals(), RFC(4647))
Esempio n. 17
0
# -*- coding: utf-8; -*-

from httpolice.citation import RFC
from httpolice.parse import auto, fill_names, pivot, string, string_times
from httpolice.structure import CaseInsensitive
from httpolice.syntax.common import ALPHA, DIGIT


alphanum = ALPHA | DIGIT                                                > auto
language_range = CaseInsensitive << (
    string_times(1, 8, ALPHA) + string('-' + string_times(1, 8, alphanum)) |
    '*')                                                                > pivot


fill_names(globals(), RFC(4647))
Esempio n. 18
0
from httpolice.citation import RFC
from httpolice.parse import (auto, fill_names, many, octet, octet_range, pivot,
                             skip, string1)
from httpolice.syntax.common import SP
from httpolice.syntax.rfc3986 import URI_reference

NQSCHAR = (octet_range(0x20, 0x21) | octet_range(0x23, 0x5B)
           | octet_range(0x5D, 0x7E)) > auto
NQCHAR = (octet(0x21) | octet_range(0x23, 0x5B)
          | octet_range(0x5D, 0x7E)) > auto

scope_token = string1(NQCHAR) > pivot
scope = scope_token % many(skip(SP) * scope_token) > pivot

error = string1(NQSCHAR) > pivot
error_description = string1(NQSCHAR) > pivot
error_uri = URI_reference > pivot

fill_names(globals(), RFC(6749))
Esempio n. 19
0
# This has been slightly adapted to the rules of RFC 7230.
# The ``OWS`` are derived from the "implied ``*LWS``" requirement.


# We have no need to special-case "inline" and "attachment", simplify.
disposition_type = CaseInsensitive << token                             > pivot

filename_parm = (
    (CaseInsensitive << literal('filename')) *
    skip(OWS * '=' * OWS) * value |
    (CaseInsensitive << literal('filename*')) *
    skip(OWS * '=' * OWS) * ext_value)                                  > pivot

# ``token`` is a superset of ``ext-token``,
# and special-casing ``ext-token`` requires
# something more complex than our `string_excluding`.
# Until then, we can simplify a bit.
disp_ext_parm = (
    (CaseInsensitive << token__excluding(['filename', 'filename*'])) *
    skip(OWS * '=' * OWS) * value)                                      > pivot

disposition_parm = filename_parm | disp_ext_parm                        > auto

content_disposition = Parametrized << (
    disposition_type *
    (MultiDict << many(skip(OWS * ';' * OWS) * disposition_parm)))      > pivot


fill_names(globals(), RFC(6266))
Esempio n. 20
0
             | 'i-enochian' | 'i-hak' | 'i-klingon' | 'i-lux' | 'i-mingo'
             | 'i-navajo' | 'i-pwn' | 'i-tao' | 'i-tay' | 'i-tsu' | 'sgn-BE-FR'
             | 'sgn-BE-NL' | 'sgn-CH-DE') > auto

regular = (literal('art-lojban') | 'cel-gaulish' | 'no-bok' | 'no-nyn'
           | 'zh-guoyu' | 'zh-hakka' | 'zh-min' | 'zh-min-nan'
           | 'zh-xiang') > auto

grandfathered = irregular | regular > pivot
privateuse = 'x' + string1('-' + string_times(1, 8, alphanum)) > pivot

extlang = (string_times(3, 3, ALPHA) +
           string_times(0, 2, '-' + string_times(3, 3, ALPHA))) > pivot

language = (string_times(2, 3, ALPHA) + maybe_str('-' + extlang)
            | string_times(4, 4, ALPHA) | string_times(5, 8, ALPHA)) > pivot
script = string_times(4, 4, ALPHA) > pivot
region = string_times(2, 2, ALPHA) | string_times(3, 3, DIGIT) > pivot
variant = (string_times(5, 8, alphanum) |
           (DIGIT + string_times(3, 3, alphanum))) > pivot
extension = (singleton + string1('-' + string_times(2, 8, alphanum))) > pivot

langtag = (language + maybe_str('-' + script) + maybe_str('-' + region) +
           string('-' + variant) + string('-' + extension) +
           maybe_str('-' + privateuse)) > pivot

Language_Tag = (LanguageTag << langtag | LanguageTag << privateuse
                | LanguageTag << grandfathered) > pivot

fill_names(globals(), RFC(5646))
Esempio n. 21
0
protocol_id = _check_protocol_id << token > pivot


@can_complain
def _check_alt_authority(complain, value):
    return parse(value,
                 maybe_str(uri_host) + ':' + port,
                 complain,
                 1257,
                 authority=value)


alt_authority = _check_alt_authority << quoted_string > pivot

alternative = protocol_id * skip('=') * alt_authority > pivot
parameter = ((AltSvcParam << token) * skip('=') *
             (token | quoted_string)) > pivot
alt_value = Parametrized << (
    alternative *
    (MultiDict << many(skip(OWS * ';' * OWS) * parameter))) > pivot

Alt_Svc = clear | comma_list1(alt_value) > pivot

ma = delta_seconds > pivot
persist = subst(True) << literal('1') > pivot

Alt_Used = uri_host + maybe_str(':' + port) > pivot

fill_names(globals(), RFC(7838))
Esempio n. 22
0
    # RFC 7240 Section 2: "Empty or zero-length values on both
    # the preference token and within parameters are equivalent
    # to no value being specified at all."
    (name, value) = x if isinstance(x, tuple) else (x, None)
    return Parametrized(name, None if value == u'' else value)

def preference_parameter(head=False):
    # The head (first) ``preference-parameter`` of a ``preference``
    # contains the actual preference name, which we want to annotate.
    name_cls = Preference if head else CaseInsensitive
    return (
        _normalize_empty_value << (parameter(name_cls=name_cls) |
                                   name_cls << token)
    ) > named(u'preference-parameter', RFC(7240, errata=4439), is_pivot=True)

preference = Parametrized << (
    preference_parameter(head=True) *
    many(skip(OWS * ';') * maybe(skip(OWS) * preference_parameter()))
) > named(u'preference', RFC(7240, errata=4439), is_pivot=True)

Prefer = comma_list1(preference)                                        > pivot

Preference_Applied = comma_list1(preference_parameter(head=True))       > pivot


return_ = CaseInsensitive << (literal('representation') | 'minimal')    > pivot
wait = delay_seconds                                                    > auto
handling = CaseInsensitive << (literal('strict') | 'lenient')           > pivot

fill_names(globals(), RFC(7240))
Esempio n. 23
0
from httpolice.syntax.rfc2616 import value
from httpolice.syntax.rfc5987 import ext_value
from httpolice.syntax.rfc7230 import OWS, token, token__excluding

# This has been slightly adapted to the rules of RFC 7230.
# The ``OWS`` are derived from the "implied ``*LWS``" requirement.

# We have no need to special-case "inline" and "attachment", simplify.
disposition_type = CaseInsensitive << token > pivot

filename_parm = (
    (CaseInsensitive << literal('filename')) * skip(OWS * '=' * OWS) * value |
    (CaseInsensitive << literal('filename*')) * skip(OWS * '=' * OWS) *
    ext_value) > pivot

# ``token`` is a superset of ``ext-token``,
# and special-casing ``ext-token`` requires
# something more complex than our `string_excluding`.
# Until then, we can simplify a bit.
disp_ext_parm = (
    (CaseInsensitive << token__excluding(['filename', 'filename*'])) *
    skip(OWS * '=' * OWS) * value) > pivot

disposition_parm = filename_parm | disp_ext_parm > auto

content_disposition = Parametrized << (
    disposition_type *
    (MultiDict << many(skip(OWS * ';' * OWS) * disposition_parm))) > pivot

fill_names(globals(), RFC(6266))
Esempio n. 24
0
parmname = parmname__excluding([])

# We don't need to special-case "UTF-8" and "ISO-8859-1", simplify.
mime_charsetc = (ALPHA | DIGIT | '!' | '#' | '$' | '%' | '&' | '+' | '-' | '^'
                 | '_' | '`' | '{' | '}' | '~') > auto
mime_charset = string1(mime_charsetc) > auto
charset = CaseInsensitive << mime_charset > pivot

pct_encoded = '%' + HEXDIG + HEXDIG > auto
value_chars = pct_decode << (
    force_bytes << string(pct_encoded | attr_char)) > auto


@can_complain
def _check_ext_value(complain, val):
    if val.charset in [u'UTF-8', u'ISO-8859-1']:
        try:
            val.value_bytes.decode(val.charset)
        except UnicodeError as e:
            complain(1254, charset=val.charset, error=e)
    else:
        complain(1253, charset=val.charset)
    return val


ext_value = _check_ext_value << (
    ExtValue <<
    (charset * skip("'") * maybe(language) * skip("'") * value_chars)) > pivot

fill_names(globals(), RFC(5987))
Esempio n. 25
0
parmname = string(attr_char) > pivot

# We don't need to special-case "UTF-8", simplify.
mime_charsetc = (ALPHA | DIGIT | '!' | '#' | '$' | '%' | '&' | '+' | '-' | '^'
                 | '_' | '`' | '{' | '}' | '~') > auto
mime_charset = string1(mime_charsetc) > auto
charset = CaseInsensitive << mime_charset > pivot

pct_encoded = '%' + HEXDIG + HEXDIG > auto
value_chars = pct_decode << (
    force_bytes << string(pct_encoded | attr_char)) > auto


@can_complain
def _check_ext_value(complain, val):
    if val.charset == u'UTF-8':
        try:
            val.value_bytes.decode(val.charset)
        except UnicodeError as e:
            complain(1254, charset=val.charset, error=e)
    else:
        complain(1253, charset=val.charset)
    return val


ext_value = _check_ext_value << (
    ExtValue <<
    (charset * skip("'") * maybe(language) * skip("'") * value_chars)) > pivot

fill_names(globals(), RFC(8187))
Esempio n. 26
0
host = IP_literal | IPv4address | reg_name > pivot
port = string(DIGIT) > pivot
authority = maybe_str(userinfo + '@') + host + maybe_str(':' + port) > pivot

path_abempty = string('/' + segment) > auto
path_absolute = '/' + maybe_str(segment_nz + string('/' + segment)) > auto
path_noscheme = segment_nz_nc + string('/' + segment) > auto
path_rootless = segment_nz + string('/' + segment) > auto
path_empty = subst(u'') << empty > auto

hier_part = ('//' + authority + path_abempty | path_absolute | path_rootless
             | path_empty) > pivot

query = string(pchar | '/' | '?') > pivot
fragment = string(pchar | '/' | '?') > pivot

absolute_URI = scheme + ':' + hier_part + maybe_str('?' + query) > pivot

relative_part = ('//' + authority + path_abempty | path_absolute
                 | path_noscheme | path_empty) > pivot

URI = (scheme + ':' + hier_part + maybe_str('?' + query) +
       maybe_str('#' + fragment)) > pivot

relative_ref = (relative_part + maybe_str('?' + query) +
                maybe_str('#' + fragment)) > pivot

URI_reference = URI | relative_ref > pivot

fill_names(globals(), RFC(3986))
Esempio n. 27
0
from httpolice.parse import (auto, can_complain, fill_names, maybe, octet,
                             octet_range, pivot, string, subst)
from httpolice.structure import EntityTag
from httpolice.syntax.common import DQUOTE
from httpolice.syntax.rfc7230 import comma_list1, obs_text
from httpolice.syntax.rfc7231 import HTTP_date

weak = subst(True) << octet(0x57) * octet(0x2F) > auto
etagc = octet(0x21) | octet_range(0x23, 0x7E) | obs_text > auto


@can_complain
def _no_backslashes(complain, s):
    if u'\\' in s:
        complain(1119)
    return s


opaque_tag = _no_backslashes << DQUOTE + string(etagc) + DQUOTE > auto
entity_tag = EntityTag << maybe(weak, False) * opaque_tag > pivot

ETag = entity_tag > pivot
Last_Modified = HTTP_date > pivot

If_Match = '*' | comma_list1(entity_tag) > pivot
If_None_Match = '*' | comma_list1(entity_tag) > pivot
If_Modified_Since = HTTP_date > pivot
If_Unmodified_Since = HTTP_date > pivot

fill_names(globals(), RFC(7232))
Esempio n. 28
0
# -*- coding: utf-8; -*-

from httpolice.citation import Citation
from httpolice.parse import fill_names, pivot
from httpolice.syntax.rfc7230 import comma_list
from httpolice.syntax.rfc7231 import media_range

Accept_Post = comma_list(media_range()) > pivot

fill_names(
    globals(),
    Citation(u'W3C Linked Data Platform 1.0',
             u'https://www.w3.org/TR/2015/REC-ldp-20150226/'))
Esempio n. 29
0
from httpolice.citation import RFC
from httpolice.parse import fill_names, pivot
from httpolice.syntax.rfc7230 import comma_list1
from httpolice.syntax.rfc7231 import media_type

Accept_Patch = comma_list1(media_type) > pivot

fill_names(globals(), RFC(5789))
Esempio n. 30
0
from httpolice.citation import RFC
from httpolice.parse import (
    auto,
    fill_names,
    many,
    octet,
    octet_range,
    pivot,
    skip,
    string1,
)
from httpolice.syntax.common import SP
from httpolice.syntax.rfc3986 import URI_reference


NQSCHAR = (octet_range(0x20, 0x21) | octet_range(0x23, 0x5B) |
           octet_range(0x5D, 0x7E))                                     > auto
NQCHAR = (octet(0x21) | octet_range(0x23, 0x5B) |
          octet_range(0x5D, 0x7E))                                      > auto

scope_token = string1(NQCHAR)                                           > pivot
scope = scope_token % many(skip(SP) * scope_token)                      > pivot

error = string1(NQSCHAR)                                                > pivot
error_description = string1(NQSCHAR)                                    > pivot
error_uri = URI_reference                                               > pivot


fill_names(globals(), RFC(6749))
Esempio n. 31
0
# -*- coding: utf-8; -*-

from httpolice.citation import Citation
from httpolice.parse import fill_names, pivot
from httpolice.syntax.rfc7230 import comma_list
from httpolice.syntax.rfc7231 import media_range

Accept_Post = comma_list(media_range()) > pivot

fill_names(
    globals(),
    Citation(u'W3C Linked Data Platform 1.0', u'https://www.w3.org/TR/ldp/'))
Esempio n. 32
0
# -*- coding: utf-8; -*-

from httpolice.citation import RFC
from httpolice.parse import auto, fill_names, octet_range
from httpolice.syntax.rfc7230 import quoted_string, token


LOALPHA = octet_range(0x61, 0x7A)                                       > auto

value = token | quoted_string                                           > auto


fill_names(globals(), RFC(2616))
Esempio n. 33
0
Age = delta_seconds                                                     > pivot

cache_directive = Parametrized << (
    (CacheDirective << token) *
    maybe(skip('=') * (mark(token) | mark(quoted_string))))             > pivot
Cache_Control = comma_list1(cache_directive)                            > pivot

Expires = HTTP_date                                                     > pivot

def extension_pragma(exclude_no_cache=False):
    return Parametrized << (
        (token__excluding(['no-cache']) if exclude_no_cache else token) *
        maybe(skip('=') * (token | quoted_string))
    ) > named(u'extension-pragma', RFC(7234), is_pivot=True)

pragma_directive = (CaseInsensitive << literal('no-cache') |
                    extension_pragma(exclude_no_cache=True))            > pivot
Pragma = comma_list1(pragma_directive)                                  > pivot

warn_code = WarnCode << string_times(3, 3, DIGIT)                       > pivot
warn_agent = uri_host + maybe_str(':' + port) | pseudonym               > pivot
warn_text = quoted_string                                               > pivot
warn_date = skip(DQUOTE) * HTTP_date * skip(DQUOTE)                     > pivot
warning_value = WarningValue << (warn_code * skip(SP) *
                                 warn_agent * skip(SP) *
                                 warn_text *
                                 maybe(skip(SP) * warn_date))           > pivot
Warning_ = comma_list1(warning_value)                                   > pivot

fill_names(globals(), RFC(7234))
Esempio n. 34
0
        complain(1309)
    return MultiDict(r)

link_param = (
    (CaseInsensitive << token) * skip(BWS) *
    maybe(skip(literal('=') * BWS) * (mark(token) |
                                      mark(quoted_string))))            > pivot

link_value = Parametrized << (
    skip('<') * URI_Reference * skip('>') *
    (_process_params << many(skip(OWS * ';' * OWS) * link_param)))      > pivot

Link = comma_list(link_value)                                           > pivot


anchor = URI_Reference                                                  > auto

reg_rel_type = CaseInsensitive << (
    LOALPHA + string(LOALPHA | DIGIT | '.' | '-'))                      > auto
ext_rel_type = URI                                                      > auto
relation_type = reg_rel_type | ext_rel_type                             > pivot
rel = rev = relation_type % many(skip(string1(SP)) * relation_type)     > auto

hreflang = Language_Tag                                                 > auto

type_ = check_media_type << (
    MediaType << type_name + '/' + subtype_name)                        > auto


fill_names(globals(), RFC(8288))