示例#1
0
文件: headers.py 项目: dowski/aspen
 def __init__(self, headers):
     """Takes headers as a string.
     """
     diesel_headers = DieselHeaders()
     diesel_headers.parse(headers)
     self._diesel_headers = diesel_headers
     Mapping.__init__(self)
     self._dict.update(diesel_headers._headers)
示例#2
0
文件: headers.py 项目: dowski/aspen
 def __init__(self, headers):
     """Takes headers as a string.
     """
     diesel_headers = DieselHeaders()
     diesel_headers.parse(headers)
     self._diesel_headers = diesel_headers
     Mapping.__init__(self)
     self._dict.update(diesel_headers._headers)
示例#3
0
 def __init__(self, raw):
     """Takes a string of type application/x-www-form-urlencoded.
     """
     self.decoded = urllib.unquote_plus(raw).decode('UTF-8')
     self.raw = raw
     Mapping.__init__(self, cgi.parse_qs( self.decoded
                                        , keep_blank_values = True
                                        , strict_parsing = False
                                         ))
示例#4
0
 def __init__(self, headers):
     """Takes headers as a string.
     """
     Mapping.__init__(self)
     hd = defaultdict(list)
     for line in headers.splitlines():
         k, v = line.strip().split(':', 1)
         hd[k.strip().lower()].append(v.strip())
     self._dict.update(hd)
示例#5
0
 def __init__(self, headers):
     """Takes headers as a string.
     """
     Mapping.__init__(self)
     hd = {}
     for line in headers.splitlines():
         k, v = line.strip().split(': ', 1)
         hd[k.lower()] = v
     self._dict.update(hd)
示例#6
0
    def __init__(self, raw):
        """Takes a string of type application/x-www-form-urlencoded.
        """
        self.decoded = urllib.unquote_plus(raw).decode("UTF-8")
        self.raw = raw

        # parse_qs does its own unquote_plus'ing ...
        as_dict = cgi.parse_qs(raw, keep_blank_values=True, strict_parsing=False)

        # ... but doesn't decode to unicode.
        for k, vals in as_dict.items():
            as_dict[k.decode("UTF-8")] = [v.decode("UTF-8") for v in vals]

        Mapping.__init__(self, as_dict)
示例#7
0
    def __init__(self, raw):
        """Takes a string of type application/x-www-form-urlencoded.
        """
        self.decoded = urllib.unquote_plus(raw).decode('UTF-8')
        self.raw = raw

        # parse_qs does its own unquote_plus'ing ...
        as_dict = cgi.parse_qs(raw,
                               keep_blank_values=True,
                               strict_parsing=False)

        # ... but doesn't decode to unicode.
        for k, vals in as_dict.items():
            as_dict[k.decode('UTF-8')] = [v.decode('UTF-8') for v in vals]

        Mapping.__init__(self, as_dict)