Merge "Force header keys/values to bytes/unicode before coercing to unicode"
This commit is contained in:
		@@ -169,6 +169,8 @@ def http_log(args, kwargs, resp, body):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def parse_header_string(data):
 | 
					def parse_header_string(data):
 | 
				
			||||||
 | 
					    if not isinstance(data, (six.text_type, six.binary_type)):
 | 
				
			||||||
 | 
					        data = str(data)
 | 
				
			||||||
    if six.PY2:
 | 
					    if six.PY2:
 | 
				
			||||||
        if isinstance(data, six.text_type):
 | 
					        if isinstance(data, six.text_type):
 | 
				
			||||||
            # Under Python2 requests only returns binary_type, but if we get
 | 
					            # Under Python2 requests only returns binary_type, but if we get
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1203,13 +1203,16 @@ class TestPostObject(MockHttpTest):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    def test_ok(self):
 | 
					    def test_ok(self):
 | 
				
			||||||
        c.http_connection = self.fake_http_connection(200)
 | 
					        c.http_connection = self.fake_http_connection(200)
 | 
				
			||||||
 | 
					        delete_at = 2.1  # not str! we don't know what other devs will use!
 | 
				
			||||||
        args = ('http://www.test.com', 'token', 'container', 'obj',
 | 
					        args = ('http://www.test.com', 'token', 'container', 'obj',
 | 
				
			||||||
                {'X-Object-Meta-Test': 'mymeta'})
 | 
					                {'X-Object-Meta-Test': 'mymeta',
 | 
				
			||||||
 | 
					                 'X-Delete-At': delete_at})
 | 
				
			||||||
        c.post_object(*args)
 | 
					        c.post_object(*args)
 | 
				
			||||||
        self.assertRequests([
 | 
					        self.assertRequests([
 | 
				
			||||||
            ('POST', '/container/obj', '', {
 | 
					            ('POST', '/container/obj', '', {
 | 
				
			||||||
                'x-auth-token': 'token',
 | 
					                'x-auth-token': 'token',
 | 
				
			||||||
                'X-Object-Meta-Test': 'mymeta'}),
 | 
					                'X-Object-Meta-Test': 'mymeta',
 | 
				
			||||||
 | 
					                'X-Delete-At': delete_at}),
 | 
				
			||||||
        ])
 | 
					        ])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def test_unicode_ok(self):
 | 
					    def test_unicode_ok(self):
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user