Beispiel #1
0
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)
Beispiel #2
0
from httpolice.citation import RFC
from httpolice.parse import (auto, can_complain, fill_names, literal, maybe,
                             pivot, skip, string, string1, subst)
from httpolice.structure import (CaseInsensitive, ContentRange, RangeSpecifier,
                                 RangeUnit)
from httpolice.syntax.common import CHAR, DIGIT, SP, VCHAR
from httpolice.syntax.rfc7230 import comma_list1, token__excluding
from httpolice.syntax.rfc7231 import HTTP_date
from httpolice.syntax.rfc7232 import entity_tag

bytes_unit = RangeUnit << literal('bytes') > auto
other_range_unit = RangeUnit << token__excluding(['bytes']) > auto
range_unit = bytes_unit | other_range_unit > pivot
acceptable_ranges = (CaseInsensitive << literal('none')
                     | comma_list1(range_unit)) > pivot
Accept_Ranges = acceptable_ranges > pivot


@can_complain
def _well_formed1(complain, first, last):
    if (last is not None) and (first > last):
        complain(1133)
    return (first, last)


first_byte_pos = int << string1(DIGIT) > auto
last_byte_pos = int << string1(DIGIT) > auto
byte_range_spec = _well_formed1 << (first_byte_pos * skip('-') *
                                    maybe(last_byte_pos)) > pivot

suffix_length = int << string1(DIGIT) > auto
Beispiel #3
0
def parameter(exclude=None):
    return (
        (CaseInsensitive << token__excluding(exclude or [])) *
        skip('=') * (token | quoted_string)
    ) > named(u'parameter', RFC(7231), is_pivot=True)
Beispiel #4
0
def parameter(exclude=None):
    return ((CaseInsensitive << token__excluding(exclude or [])) * skip('=') *
            (token | quoted_string)) > named(
                u'parameter', RFC(7231), is_pivot=True)
Beispiel #5
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))
Beispiel #6
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))
Beispiel #7
0
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)
Beispiel #8
0
# -*- coding: utf-8; -*-

from httpolice.citation import RFC
from httpolice.parse import (auto, can_complain, fill_names, literal, maybe,
                             pivot, skip, string, string1, subst)
from httpolice.structure import ContentRange, RangeSpecifier, RangeUnit
from httpolice.syntax.common import CHAR, DIGIT, SP, VCHAR
from httpolice.syntax.rfc7230 import comma_list1, token__excluding
from httpolice.syntax.rfc7231 import HTTP_date
from httpolice.syntax.rfc7232 import entity_tag


bytes_unit = RangeUnit << literal('bytes')                              > auto
other_range_unit = RangeUnit << token__excluding(['bytes'])             > auto
range_unit = bytes_unit | other_range_unit                              > pivot
acceptable_ranges = (
    subst([]) << literal('none') |
    comma_list1(range_unit))                                            > pivot
Accept_Ranges = acceptable_ranges                                       > pivot

@can_complain
def _well_formed1(complain, first, last):
    if (last is not None) and (first > last):
        complain(1133)
    return (first, last)

first_byte_pos = int << string1(DIGIT)                                  > auto
last_byte_pos = int << string1(DIGIT)                                   > auto
byte_range_spec = _well_formed1 << (first_byte_pos * skip('-') *
                                    maybe(last_byte_pos))               > pivot