Example #1
0
    def test_dump_response_head_5416(self):
        """
        :see: https://github.com/andresriancho/w3af/issues/5416
        """
        url = URL('http://w3af.com')
        headers = Headers()
        msg = 'D\xe9plac\xe9 Temporairement'
        resp = HTTPResponse(200, '', headers, url, url, msg=msg)

        expected_dump = u'HTTP/1.1 200 Déplacé Temporairement\r\n'.encode(
            'utf8')

        self.assertEqual(resp.dump_response_head(), expected_dump)
Example #2
0
    def test_dump_response_head_3661(self):
        """
        :see: https://github.com/andresriancho/w3af/issues/3661
        """
        url = URL('http://w3af.com')
        # '\xf3' is o-tilde in windows-1251
        #
        # We get from that arbitrary character to o-tilde in windows-1251 when
        # we fail to decode it, and chardet guesses the encoding.
        headers = Headers([('Content-Type', '\xf3')])
        resp = HTTPResponse(200, '', headers, url, url)

        # '\xc3\xb3' is o-tilde in utf-8
        expected_dump = 'HTTP/1.1 200 OK\r\nContent-Type: \xc3\xb3\r\n'

        self.assertEqual(resp.dump_response_head(), expected_dump)