示例#1
0
 def test_contentEncoding(self):
     """
     Use the encoding specified in the ``Content-Type`` header.
     """
     headers = Headers({b'Content-Type': [b'text/plain;charset=utf-32']})
     self.assertThat(
         contentEncoding(headers),
         Equals(b'utf-32'))
示例#2
0
 def test_customDefault(self):
     """
     Allow specifying a default encoding.
     """
     headers = Headers()
     self.assertThat(
         contentEncoding(headers, b'utf-32'),
         Equals(b'utf-32'))
示例#3
0
 def test_default(self):
     """
     If there is no ``Content-Type`` header then use the default encoding.
     """
     headers = Headers()
     self.assertThat(
         contentEncoding(headers),
         Equals(b'utf-8'))
示例#4
0
 def test_noCharset(self):
     """
     If the ``Content-Type`` header does not specify a charset then use the
     default encoding.
     """
     headers = Headers({'Content-Type': ['text/plain']})
     self.assertThat(
         contentEncoding(headers),
         Equals(b'utf-8'))
示例#5
0
 def _match(request, value):
     return name, query.Integer(value, base=base, encoding=contentEncoding(request.requestHeaders, encoding))
示例#6
0
 def _match(request, value):
     return name, query.Text(value, encoding=contentEncoding(request.requestHeaders, encoding))