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

Side by Side Diff: client/utils/net.py

Issue 2921943002: Fix GS URL regex (Closed)
Patch Set: Created 3 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2013 The LUCI Authors. All rights reserved. 1 # Copyright 2013 The LUCI Authors. All rights reserved.
2 # Use of this source code is governed under the Apache License, Version 2.0 2 # Use of this source code is governed under the Apache License, Version 2.0
3 # that can be found in the LICENSE file. 3 # that can be found in the LICENSE file.
4 4
5 """Classes and functions for generic network communication over HTTP.""" 5 """Classes and functions for generic network communication over HTTP."""
6 6
7 import cookielib 7 import cookielib
8 import httplib 8 import httplib
9 import itertools 9 import itertools
10 import json 10 import json
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 # Content type -> function that encodes a request body. 62 # Content type -> function that encodes a request body.
63 CONTENT_ENCODERS = { 63 CONTENT_ENCODERS = {
64 URL_ENCODED_FORM_CONTENT_TYPE: 64 URL_ENCODED_FORM_CONTENT_TYPE:
65 urllib.urlencode, 65 urllib.urlencode,
66 JSON_CONTENT_TYPE: 66 JSON_CONTENT_TYPE:
67 lambda x: json.dumps(x, sort_keys=True, separators=(',', ':')), 67 lambda x: json.dumps(x, sort_keys=True, separators=(',', ':')),
68 } 68 }
69 69
70 70
71 # Google Storage URL regular expression. 71 # Google Storage URL regular expression.
72 GS_STORAGE_HOST_URL_RE = re.compile(r'https://.*\.storage\.googleapis\.com') 72 GS_STORAGE_HOST_URL_RE = re.compile(r'https://(.*\.)?storage\.googleapis\.com')
M-A Ruel 2017/06/02 17:26:23 It should be a + instead of a *, then lgtm
nodir 2017/06/02 17:28:03 Done.
73 73
74 # Global (for now) map: server URL (http://example.com) -> HttpService instance. 74 # Global (for now) map: server URL (http://example.com) -> HttpService instance.
75 # Used by get_http_service to cache HttpService instances. 75 # Used by get_http_service to cache HttpService instances.
76 _http_services = {} 76 _http_services = {}
77 _http_services_lock = threading.Lock() 77 _http_services_lock = threading.Lock()
78 78
79 # This lock ensures that user won't be confused with multiple concurrent 79 # This lock ensures that user won't be confused with multiple concurrent
80 # login prompts. 80 # login prompts.
81 _auth_lock = threading.Lock() 81 _auth_lock = threading.Lock()
82 82
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 attemp_obj = RetryAttempt(attempt, remaining) 802 attemp_obj = RetryAttempt(attempt, remaining)
803 yield attemp_obj 803 yield attemp_obj
804 if attemp_obj.skip_sleep: 804 if attemp_obj.skip_sleep:
805 continue 805 continue
806 # Only sleep if we are going to try again. 806 # Only sleep if we are going to try again.
807 if max_attempts and attempt != max_attempts - 1: 807 if max_attempts and attempt != max_attempts - 1:
808 remaining = (timeout - (current_time() - start)) if timeout else None 808 remaining = (timeout - (current_time() - start)) if timeout else None
809 if remaining is not None and remaining < 0: 809 if remaining is not None and remaining < 0:
810 break 810 break
811 sleep_before_retry(attempt, remaining) 811 sleep_before_retry(attempt, remaining)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698