Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(626)

Side by Side Diff: client/third_party/infra_libs/httplib2_utils.py

Issue 2991803002: Update infra_libs to 1.1.15 / 0b44aba87c1c6538439df6d24a409870810747ab (Closed)
Patch Set: fix Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 base64 5 import base64
6 import collections 6 import collections
7 import copy 7 import copy
8 import httplib
8 import json 9 import json
9 import logging 10 import logging
10 import os 11 import os
11 import re 12 import re
12 import socket 13 import socket
13 import sys 14 import sys
14 import time 15 import time
15 16
16 import httplib2 17 import httplib2
17 import oauth2client.client 18 import oauth2client.client
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 start_time = self.time_fn() 332 start_time = self.time_fn()
332 try: 333 try:
333 response, content = super(InstrumentedHttp, self).request( 334 response, content = super(InstrumentedHttp, self).request(
334 uri, method, body, *args, **kwargs) 335 uri, method, body, *args, **kwargs)
335 except socket.timeout: 336 except socket.timeout:
336 self._update_metrics(http_metrics.STATUS_TIMEOUT, start_time) 337 self._update_metrics(http_metrics.STATUS_TIMEOUT, start_time)
337 raise 338 raise
338 except (socket.error, socket.herror, socket.gaierror): 339 except (socket.error, socket.herror, socket.gaierror):
339 self._update_metrics(http_metrics.STATUS_ERROR, start_time) 340 self._update_metrics(http_metrics.STATUS_ERROR, start_time)
340 raise 341 raise
341 except httplib2.HttpLib2Error: 342 except (httplib.HTTPException, httplib2.HttpLib2Error) as ex:
342 self._update_metrics(http_metrics.STATUS_EXCEPTION, start_time) 343 status = http_metrics.STATUS_EXCEPTION
344 if 'Deadline exceeded while waiting for HTTP response' in str(ex):
345 # Raised on Appengine (gae_override/httplib.py).
346 status = http_metrics.STATUS_TIMEOUT
347 self._update_metrics(status, start_time)
343 raise 348 raise
344 http_metrics.response_bytes.add(len(content), fields=self.fields) 349 http_metrics.response_bytes.add(len(content), fields=self.fields)
345 350
346 self._update_metrics(response.status, start_time) 351 self._update_metrics(response.status, start_time)
347 352
348 return response, content 353 return response, content
349 354
350 355
351 class HttpMock(object): 356 class HttpMock(object):
352 """Mock of httplib2.Http""" 357 """Mock of httplib2.Http"""
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 self.requests_made.append(self.HttpCall(uri, method, body, headers)) 398 self.requests_made.append(self.HttpCall(uri, method, body, headers))
394 headers = None 399 headers = None
395 body = None 400 body = None
396 for candidate in self._uris: 401 for candidate in self._uris:
397 if candidate[0].match(uri): 402 if candidate[0].match(uri):
398 _, headers, body = candidate 403 _, headers, body = candidate
399 break 404 break
400 if not headers: 405 if not headers:
401 raise AssertionError("Unexpected request to %s" % uri) 406 raise AssertionError("Unexpected request to %s" % uri)
402 return httplib2.Response(headers), body 407 return httplib2.Response(headers), body
OLDNEW
« no previous file with comments | « client/third_party/infra_libs/event_mon/router.py ('k') | client/third_party/infra_libs/ts_mon/__init__.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698