| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import collections | 5 import collections |
| 6 import copy | 6 import copy |
| 7 import json | 7 import json |
| 8 import logging | 8 import logging |
| 9 import os | 9 import os |
| 10 import re | 10 import re |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 'will retry') | 199 'will retry') |
| 200 if i == self._max_tries: | 200 if i == self._max_tries: |
| 201 raise | 201 raise |
| 202 | 202 |
| 203 return response, content | 203 return response, content |
| 204 | 204 |
| 205 def __getattr__(self, name): | 205 def __getattr__(self, name): |
| 206 return getattr(self._http, name) | 206 return getattr(self._http, name) |
| 207 | 207 |
| 208 def __setattr__(self, name, value): | 208 def __setattr__(self, name, value): |
| 209 if name in ('_http', '_max_tries', '_retrying_statuses_fn'): | 209 if name in ('request', '_http', '_max_tries', '_retrying_statuses_fn'): |
| 210 self.__dict__[name] = value | 210 self.__dict__[name] = value |
| 211 else: | 211 else: |
| 212 setattr(self._http, name, value) | 212 setattr(self._http, name, value) |
| 213 | 213 |
| 214 class InstrumentedHttp(httplib2.Http): | 214 class InstrumentedHttp(httplib2.Http): |
| 215 """A httplib2.Http object that reports ts_mon metrics about its requests.""" | 215 """A httplib2.Http object that reports ts_mon metrics about its requests.""" |
| 216 | 216 |
| 217 def __init__(self, name, time_fn=time.time, timeout=DEFAULT_TIMEOUT, | 217 def __init__(self, name, time_fn=time.time, timeout=DEFAULT_TIMEOUT, |
| 218 **kwargs): | 218 **kwargs): |
| 219 """ | 219 """ |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 self.requests_made.append(self.HttpCall(uri, method, body, headers)) | 306 self.requests_made.append(self.HttpCall(uri, method, body, headers)) |
| 307 headers = None | 307 headers = None |
| 308 body = None | 308 body = None |
| 309 for candidate in self._uris: | 309 for candidate in self._uris: |
| 310 if candidate[0].match(uri): | 310 if candidate[0].match(uri): |
| 311 _, headers, body = candidate | 311 _, headers, body = candidate |
| 312 break | 312 break |
| 313 if not headers: | 313 if not headers: |
| 314 raise AssertionError("Unexpected request to %s" % uri) | 314 raise AssertionError("Unexpected request to %s" % uri) |
| 315 return httplib2.Response(headers), body | 315 return httplib2.Response(headers), body |
| OLD | NEW |