Exemplo 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'
Exemplo 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"
Exemplo 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)
Exemplo 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)
Exemplo 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
Exemplo 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)
Exemplo n.º 7
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)
Exemplo 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'
Exemplo n.º 9
0
 def access_control_expose_headers(self, value: HeaderSet) -> None:
     self.headers["Access-Control-Expose-Headers"] = dump_header(value)
Exemplo n.º 10
0
 def access_control_allow_methods(self, value: HeaderSet) -> None:
     self.headers["Access-Control-Allow-Methods"] = dump_header(value)
Exemplo 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"
Exemplo n.º 12
0
 def to_header(self):
     return dump_header(self)
Exemplo n.º 13
0
 def to_header(self):
     return dump_header(self)