コード例 #1
0
 def test_get_is_case_insensitive(self):
     h = HttpHeaders()
     h.set('Cookie', 'a=1')
     h.add_pairs([('cookie', 'b=2'), ('COOKIE', 'c=3')])
     h.add(u'CoOkIe', 'd=4')  # note: unicode
     self.assertEqual('a=1', h.get(u'COOKIE'))
     self.assertEqual(['a=1', 'b=2', 'c=3', 'd=4'],
                      list(h.get_values('Cookie')))
コード例 #2
0
    def test_unicode(self):
        # test adding unicode values in all the different ways
        h = HttpHeaders([('a', 'ሴ')])
        self.assertEqual('ሴ', h.get('a'))

        h.set('b', '𦉘')
        self.assertEqual('𦉘', h.get('b'))

        h.add('c', '👁👄👁')
        self.assertEqual('👁👄👁', h.get('c'))

        h.add_pairs([('d', 'ⓤţḟ⁻❽')])
        self.assertEqual('ⓤţḟ⁻❽', h.get('d'))
コード例 #3
0
    def test_set(self):
        h = HttpHeaders()

        # create
        h.set('Host', 'example.org')
        self.assertEqual(['example.org'], list(h.get_values('Host')))

        # replace
        h.set('Host', 'example2.org')
        self.assertEqual(['example2.org'], list(h.get_values('Host')))

        # replace many
        h.add('Host', 'example3.org')
        h.add('Host', 'example4.org')
        h.set('Host', 'example5.org')
        self.assertEqual(['example5.org'], list(h.get_values('Host')))