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'))
def test_customDefault(self): """ Allow specifying a default encoding. """ headers = Headers() self.assertThat( contentEncoding(headers, b'utf-32'), Equals(b'utf-32'))
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'))
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'))
def _match(request, value): return name, query.Integer(value, base=base, encoding=contentEncoding(request.requestHeaders, encoding))
def _match(request, value): return name, query.Text(value, encoding=contentEncoding(request.requestHeaders, encoding))