diff --git a/googleapiclient/http.py b/googleapiclient/http.py index cd2775acc70..41256668b2e 100644 --- a/googleapiclient/http.py +++ b/googleapiclient/http.py @@ -1760,16 +1760,18 @@ def request( connection_type=None, ): resp, content = self._iterable.pop(0) - if content == "echo_request_headers": + content = six.ensure_binary(content) + + if content == b"echo_request_headers": content = headers - elif content == "echo_request_headers_as_json": + elif content == b"echo_request_headers_as_json": content = json.dumps(headers) - elif content == "echo_request_body": + elif content == b"echo_request_body": if hasattr(body, "read"): content = body.read() else: content = body - elif content == "echo_request_uri": + elif content == b"echo_request_uri": content = uri if isinstance(content, six.text_type): content = content.encode("utf-8") diff --git a/googleapiclient/model.py b/googleapiclient/model.py index 554056e3ef2..7255ecf39a7 100644 --- a/googleapiclient/model.py +++ b/googleapiclient/model.py @@ -218,7 +218,7 @@ def response(self, resp, content): return self.no_content_response return self.deserialize(content) else: - LOGGER.debug("Content from bad request was: %s" % content) + LOGGER.debug("Content from bad request was: %r" % content) raise HttpError(resp, content) def serialize(self, body_value):