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

Unified Diff: media/tools/constrained_network_server/cns.py

Issue 9960063: CNS seek tests for <video>. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Value vs index Created 8 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/functional/media/media_seek_perf.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/tools/constrained_network_server/cns.py
diff --git a/media/tools/constrained_network_server/cns.py b/media/tools/constrained_network_server/cns.py
index 94a8f4914708637bdfdf3e40b68a3941a12b034f..dd8088fb773eefd560e1645dcd917b2b0fbe0085 100755
--- a/media/tools/constrained_network_server/cns.py
+++ b/media/tools/constrained_network_server/cns.py
@@ -185,7 +185,7 @@ class ConstrainedNetworkServer(object):
@cherrypy.expose
def ServeConstrained(self, f=None, bandwidth=None, latency=None, loss=None,
- new_port=False):
+ new_port=False, no_cache=False, **kwargs):
"""Serves the requested file with the requested constraints.
Subsequent requests for the same constraints from the same IP will share the
@@ -199,9 +199,16 @@ class ConstrainedNetworkServer(object):
latency: time to add to each packet (integer in ms).
loss: percentage of packets to drop (integer, 0-100).
new_port: whether to use a new port for this request or not.
+ no_cache: Set reponse's cache-control to no-cache.
"""
cherrypy.log('Got request for %s, bandwidth=%s, latency=%s, loss=%s, '
- 'new_port=%s' % (f, bandwidth, latency, loss, new_port))
+ 'new_port=%s, no_cache=%s, kwargs=%s' %
+ (f, bandwidth, latency, loss, new_port, no_cache, kwargs))
+ if no_cache:
+ response = cherrypy.response
+ response.headers['Pragma'] = 'no-cache'
+ response.headers['Cache-Control'] = 'no-cache'
+
# CherryPy is a bit wonky at detecting parameters, so just make them all
# optional and validate them ourselves.
if not f:
@@ -246,11 +253,14 @@ class ConstrainedNetworkServer(object):
cherrypy.log('Time to set up port %d = %ssec.' %
(constrained_port, end_time - start_time))
- # Build constrained URL. Only pass on the file parameter.
- constrained_url = '%s?f=%s' % (
+ # Build constrained URL using the constrained port and original URL
+ # parameters except the network constraints (bandwidth, latency, and loss).
+ constrained_url = '%s?f=%s&no_cache=%s&%s' % (
cherrypy.url().replace(
':%d' % self._options.port, ':%d' % constrained_port),
- f)
+ f,
+ no_cache,
+ '&'.join(['%s=%s' % (key, kwargs[key]) for key in kwargs]))
# Redirect request to the constrained port.
cherrypy.lib.cptools.redirect(constrained_url, internal=False)
« no previous file with comments | « chrome/test/functional/media/media_seek_perf.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698