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

Side by Side Diff: tools/telemetry/third_party/webpagereplay/mockhttprequest.py

Issue 1647513002: Delete tools/telemetry. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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
(Empty)
1 #!/usr/bin/env python
2 # Copyright 2010 Google Inc. All Rights Reserved.
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16 """Mock instance of ArchivedHttpRequest used for testing."""
17
18
19 class ArchivedHttpRequest(object):
20 """Mock instance of ArchivedHttpRequest in HttpArchive."""
21
22 def __init__(self, command, host, path, request_body, headers):
23 """Initialize an ArchivedHttpRequest.
24
25 Args:
26 command: a string (e.g. 'GET' or 'POST').
27 host: a host name (e.g. 'www.google.com').
28 path: a request path (e.g. '/search?q=dogs').
29 request_body: a request body string for a POST or None.
30 headers: [(header1, value1), ...] list of tuples
31 """
32 self.command = command
33 self.host = host
34 self.path = path
35 self.request_body = request_body
36 self.headers = headers
37 self.trimmed_headers = headers
38
39 def __str__(self):
40 return '%s %s%s %s' % (self.command, self.host, self.path,
41 self.trimmed_headers)
42
43 def __repr__(self):
44 return repr((self.command, self.host, self.path, self.request_body,
45 self.trimmed_headers))
46
47 def __hash__(self):
48 """Return a integer hash to use for hashed collections including dict."""
49 return hash(repr(self))
50
51 def __eq__(self, other):
52 """Define the __eq__ method to match the hash behavior."""
53 return repr(self) == repr(other)
54
55 def matches(self, command=None, host=None, path=None):
56 """Returns true iff the request matches all parameters."""
57 return ((command is None or command == self.command) and
58 (host is None or host == self.host) and
59 (path is None or path == self.path))
OLDNEW
« no previous file with comments | « tools/telemetry/third_party/webpagereplay/mock-archive.txt ('k') | tools/telemetry/third_party/webpagereplay/net_configs.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698