| 1796 | self.request_sequence = list() |
| 1797 | |
| 1798 | def request( |
| 1799 | self, |
| 1800 | uri, |
| 1801 | method="GET", |
| 1802 | body=None, |
| 1803 | headers=None, |
| 1804 | redirections=1, |
| 1805 | connection_type=None, |
| 1806 | ): |
| 1807 | # Remember the request so after the fact this mock can be examined |
| 1808 | self.request_sequence.append((uri, method, body, headers)) |
| 1809 | resp, content = self._iterable.pop(0) |
| 1810 | if isinstance(content, str): |
| 1811 | content = content.encode("utf-8") |
| 1812 | |
| 1813 | if content == b"echo_request_headers": |
| 1814 | content = headers |
| 1815 | elif content == b"echo_request_headers_as_json": |
| 1816 | content = json.dumps(headers) |
| 1817 | elif content == b"echo_request_body": |
| 1818 | if hasattr(body, "read"): |
| 1819 | content = body.read() |
| 1820 | else: |
| 1821 | content = body |
| 1822 | elif content == b"echo_request_uri": |
| 1823 | content = uri |
| 1824 | if isinstance(content, str): |
| 1825 | content = content.encode("utf-8") |
| 1826 | return httplib2.Response(resp), content |
| 1827 | |
| 1828 | |
| 1829 | def set_user_agent(http, user_agent): |