Пример #1
0
    def oauth_from_dict(self, dct):
        oauth = {}
        for k, v in dct.items():
            if k.startswith(OAUTH_PREFIX):
                oauth[k[len(OAUTH_PREFIX) :]] = unquote(v)

        return oauth
Пример #2
0
    def oauth_from_header(self):
        oauth = {}
        for param in [p.strip() for p in self.request.META["HTTP_AUTHORIZATION"].split(",")]:
            if param.find("OAuth realm") > -1:
                continue
            try:
                k, v = param.split("=", 1)
            except ValueError:
                continue
            if k.startswith(OAUTH_PREFIX):
                oauth[k[len(OAUTH_PREFIX) :]] = unquote(v.strip('"'))

        return oauth
Пример #3
0
 def testEncoding(self):
     params = (
         (u"abcABC123", u"abcABC123"),
         (u"-._~", u"-._~"),
         (u"%", u"%25"),
         (u"+", u"%2B"),
         (u"&=*", u"%26%3D%2A"),
         (unichr(0x000A), u"%0A"),
         (unichr(0x0020), u"%20"),
         (unichr(0x007F), u"%7F"),
         (unichr(0x0080), u"%C2%80"),
         (unichr(0x3001), u"%E3%80%81"),
     )
     for p in params:
         self.assertEqual(quote(p[0]), p[1])
         self.assertEqual(unquote(quote(p[0])), p[1])