Esempio n. 1
0
 def test_dump_header(self):
     assert http.dump_header([1, 2, 3]) == '1, 2, 3'
     assert http.dump_header([1, 2, 3],
                             allow_token=False) == '"1", "2", "3"'
     assert http.dump_header({'foo': 'bar'},
                             allow_token=False) == 'foo="bar"'
     assert http.dump_header({'foo': 'bar'}) == 'foo=bar'
Esempio n. 2
0
 def test_dump_header(self):
     assert http.dump_header([1, 2, 3]) == "1, 2, 3"
     assert http.dump_header([1, 2, 3],
                             allow_token=False) == '"1", "2", "3"'
     assert http.dump_header({"foo": "bar"},
                             allow_token=False) == 'foo="bar"'
     assert http.dump_header({"foo": "bar"}) == "foo=bar"
Esempio n. 3
0
 def fset(self, value):
     if not value:
         del self.headers[name]
     elif isinstance(value, str):
         self.headers[name] = value
     else:
         self.headers[name] = dump_header(value)
Esempio n. 4
0
 def fset(
     self: "Response",
     value: t.Optional[t.Union[str, t.Dict[str, t.Union[str, int]],
                               t.Iterable[str]]],
 ) -> None:
     if not value:
         del self.headers[name]
     elif isinstance(value, str):
         self.headers[name] = value
     else:
         self.headers[name] = dump_header(value)
Esempio n. 5
0
    def add_headers(self, response):
        response = make_response(response)
        auth = request.authorization

        hA1 = self.get_key(auth.username)
        hA2 = hash_all('', auth.uri)
        rspauth = digest(hA1, hA2)

        response.headers['Authentication-Info'] = dump_header({
            'rspauth': rspauth, 'qop': auth.qop,
            'cnonce': auth.cnonce, 'nc': auth.nc
        })

        return response
Esempio n. 6
0
 def set_digest(self, realm, nonce, qop = ('auth',), opaque = None, algorithm = None, stale = False):
     d = {'__auth_type__': 'digest',
      'realm': realm,
      'nonce': nonce,
      'qop': dump_header(qop)}
     if stale:
         d['stale'] = 'TRUE'
     if opaque is not None:
         d['opaque'] = opaque
     if algorithm is not None:
         d['algorithm'] = algorithm
     dict.clear(self)
     dict.update(self, d)
     if self.on_update:
         self.on_update(self)
 def set_digest(self, realm, nonce, qop = ('auth',), opaque = None, algorithm = None, stale = False):
     d = {'__auth_type__': 'digest',
      'realm': realm,
      'nonce': nonce,
      'qop': dump_header(qop)}
     if stale:
         d['stale'] = 'TRUE'
     if opaque is not None:
         d['opaque'] = opaque
     if algorithm is not None:
         d['algorithm'] = algorithm
     dict.clear(self)
     dict.update(self, d)
     if self.on_update:
         self.on_update(self)
Esempio n. 8
0
 def test_dump_header(self):
     assert http.dump_header([1, 2, 3]) == '1, 2, 3'
     assert http.dump_header([1, 2, 3], allow_token=False) == '"1", "2", "3"'
     assert http.dump_header({'foo': 'bar'}, allow_token=False) == 'foo="bar"'
     assert http.dump_header({'foo': 'bar'}) == 'foo=bar'
Esempio n. 9
0
 def access_control_expose_headers(self, value: HeaderSet) -> None:
     self.headers["Access-Control-Expose-Headers"] = dump_header(value)
Esempio n. 10
0
 def access_control_allow_methods(self, value: HeaderSet) -> None:
     self.headers["Access-Control-Allow-Methods"] = dump_header(value)
Esempio n. 11
0
 def test_dump_header(self):
     assert http.dump_header([1, 2, 3]) == "1, 2, 3"
     assert http.dump_header([1, 2, 3], allow_token=False) == '"1", "2", "3"'
     assert http.dump_header({"foo": "bar"}, allow_token=False) == 'foo="bar"'
     assert http.dump_header({"foo": "bar"}) == "foo=bar"
Esempio n. 12
0
 def to_header(self):
     return dump_header(self)
 def to_header(self):
     return dump_header(self)