py3: Use StringIO from six
StringIO was moved in Python3.
Use StringIO from six to maintain compatibility with python2
and python3.
Story: 2006796
Task: 42816
Signed-off-by: Charles Short <charles.short@windriver.com>
Change-Id: Ib698aa4e5815ea74e9c73c8579f95a9b411d3010
(cherry picked from commit 144f6f8113
)
This commit is contained in:
parent
46a7ccbb6c
commit
79607cdf94
|
@ -22,7 +22,7 @@ import six.moves.http_client
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import socket
|
import socket
|
||||||
import StringIO
|
from six import StringIO
|
||||||
from six.moves.urllib.parse import urlparse
|
from six.moves.urllib.parse import urlparse
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -166,9 +166,10 @@ class HTTPClient(object):
|
||||||
# Read body into string if it isn't obviously image data
|
# Read body into string if it isn't obviously image data
|
||||||
body_str = None
|
body_str = None
|
||||||
if resp.getheader('content-type', None) != 'application/octet-stream':
|
if resp.getheader('content-type', None) != 'application/octet-stream':
|
||||||
body_str = ''.join([chunk for chunk in body_iter])
|
body_str = b''.join([chunk for chunk in body_iter])
|
||||||
|
body_str = body_str.decode("utf-8")
|
||||||
self.log_http_response(resp, body_str)
|
self.log_http_response(resp, body_str)
|
||||||
body_iter = StringIO.StringIO(body_str)
|
body_iter = StringIO(body_str)
|
||||||
else:
|
else:
|
||||||
self.log_http_response(resp)
|
self.log_http_response(resp)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue