Beispiel #1
0
 def __call__(self, hdrs, content, limit):
     lines = utils.urldecode(content)
     if lines:
         body = common.format_keyvals([(k + ":", v) for (k, v) in lines],
                                      key="header",
                                      val="text")
         return "URLEncoded form", body
Beispiel #2
0
    def test_get_form_urlencoded(self):
        req = tutils.treq("foobar")
        assert req.get_form_urlencoded() == odict.ODict()

        req.headers["Content-Type"] = semantics.HDR_FORM_URLENCODED
        assert req.get_form_urlencoded() == odict.ODict(
            utils.urldecode(req.body))
Beispiel #3
0
    def test_get_urlencoded_form(self):
        request = treq(content="foobar")
        assert request.urlencoded_form is None

        request.headers["Content-Type"] = "application/x-www-form-urlencoded"
        assert request.urlencoded_form == ODict(
            utils.urldecode(request.content))
Beispiel #4
0
 def get_query(self):
     """
         Gets the request query string. Returns an ODict object.
     """
     _, _, _, _, query, _ = urlparse.urlparse(self.get_url())
     if query:
         return ODict(utils.urldecode(query))
     return ODict([])
Beispiel #5
0
 def get_query(self):
     """
         Gets the request query string. Returns an ODict object.
     """
     _, _, _, _, query, _ = urlparse.urlparse(self.get_url())
     if query:
         return ODict(utils.urldecode(query))
     return ODict([])
Beispiel #6
0
 def __call__(self, hdrs, content, limit):
     lines = utils.urldecode(content)
     if lines:
         body = common.format_keyvals(
             [(k + ":", v) for (k, v) in lines],
             key = "header",
             val = "text"
         )
         return "URLEncoded form", body
Beispiel #7
0
 def query(self):
     """
     The request query string as an :py:class:`ODict` object.
     None, if there is no query.
     """
     _, _, _, _, query, _ = urllib.parse.urlparse(self.url)
     if query:
         return ODict(utils.urldecode(query))
     return None
Beispiel #8
0
 def urlencoded_form(self):
     """
     The URL-encoded form data as an :py:class:`ODict` object.
     None if there is no data or the content-type indicates non-form data.
     """
     is_valid_content_type = "application/x-www-form-urlencoded" in self.headers.get("content-type", "").lower()
     if self.content and is_valid_content_type:
         return ODict(utils.urldecode(self.content))
     return None
Beispiel #9
0
 def get_form_urlencoded(self):
     """
         Retrieves the URL-encoded form data, returning an ODict object.
         Returns an empty ODict if there is no data or the content-type
         indicates non-form data.
     """
     if self.content and self.headers.in_any("content-type", HDR_FORM_URLENCODED, True):
         return ODict(utils.urldecode(self.content))
     return ODict([])
Beispiel #10
0
 def urlencoded_form(self):
     """
     The URL-encoded form data as an :py:class:`ODict` object.
     None if there is no data or the content-type indicates non-form data.
     """
     is_valid_content_type = "application/x-www-form-urlencoded" in self.headers.get("content-type", "").lower()
     if self.content and is_valid_content_type:
         return ODict(utils.urldecode(self.content))
     return None
Beispiel #11
0
 def query(self):
     """
     The request query string as an :py:class:`ODict` object.
     None, if there is no query.
     """
     _, _, _, _, query, _ = urllib.parse.urlparse(self.url)
     if query:
         return ODict(utils.urldecode(query))
     return None
Beispiel #12
0
 def get_form_urlencoded(self):
     """
         Retrieves the URL-encoded form data, returning an ODict object.
         Returns an empty ODict if there is no data or the content-type
         indicates non-form data.
     """
     if self.body and HDR_FORM_URLENCODED in self.headers.get("content-type", "").lower():
         return odict.ODict(utils.urldecode(self.body))
     return odict.ODict([])
Beispiel #13
0
 def get_form_urlencoded(self):
     """
         Retrieves the URL-encoded form data, returning an ODict object.
         Returns an empty ODict if there is no data or the content-type
         indicates non-form data.
     """
     if self.body and HDR_FORM_URLENCODED in self.headers.get(
             "content-type", "").lower():
         return odict.ODict(utils.urldecode(self.body))
     return odict.ODict([])
Beispiel #14
0
 def get_form_urlencoded(self):
     """
         Retrieves the URL-encoded form data, returning an ODict object.
         Returns an empty ODict if there is no data or the content-type
         indicates non-form data.
     """
     if self.content and self.headers.in_any("content-type",
                                             HDR_FORM_URLENCODED, True):
         return ODict(utils.urldecode(self.content))
     return ODict([])
Beispiel #15
0
    def test_get_urlencoded_form(self):
        request = treq(content="foobar")
        assert request.urlencoded_form is None

        request.headers["Content-Type"] = "application/x-www-form-urlencoded"
        assert request.urlencoded_form == ODict(utils.urldecode(request.content))
Beispiel #16
0
def test_urldecode():
    s = "one=two&three=four"
    assert len(utils.urldecode(s)) == 2
Beispiel #17
0
    def test_get_form_urlencoded(self):
        req = tutils.treq(body="foobar")
        assert req.get_form_urlencoded() == ODict()

        req.headers["Content-Type"] = HDR_FORM_URLENCODED
        assert req.get_form_urlencoded() == ODict(utils.urldecode(req.body))
Beispiel #18
0
 def __call__(self, data, **metadata):
     d = urldecode(data)
     return "URLEncoded form", format_dict(ODict(d))
Beispiel #19
0
 def _get_query(self):
     _, _, _, _, query, _ = urllib.parse.urlparse(self.url)
     return tuple(utils.urldecode(query))
Beispiel #20
0
 def __call__(self, data, **metadata):
     d = urldecode(data)
     return "URLEncoded form", format_dict(ODict(d))
Beispiel #21
0
def test_urldecode():
    s = "one=two&three=four"
    assert len(utils.urldecode(s)) == 2
Beispiel #22
0
 def _get_urlencoded_form(self):
     is_valid_content_type = "application/x-www-form-urlencoded" in self.headers.get("content-type", "").lower()
     if is_valid_content_type:
         return tuple(utils.urldecode(self.content))
     return ()
    def test_get_form_urlencoded(self):
        req = tutils.treq("foobar")
        assert req.get_form_urlencoded() == odict.ODict()

        req.headers["Content-Type"] = [semantics.HDR_FORM_URLENCODED]
        assert req.get_form_urlencoded() == odict.ODict(utils.urldecode(req.body))