Chromium Code Reviews| 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..2164add4141b3502d665518b95a8a501c9a4be8f 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,15 @@ 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)) |
| + if no_cache: |
| + response = cherrypy.response |
| + response.headers['Pragma'] = 'no-cache' |
| + response.headers['Cache-Control'] = 'no-cache' |
| + |
|
shadi
2012/04/18 02:03:17
I do not use this yet since <video> caches anyway
|
| # CherryPy is a bit wonky at detecting parameters, so just make them all |
| # optional and validate them ourselves. |
| if not f: |
| @@ -247,10 +253,11 @@ class ConstrainedNetworkServer(object): |
| (constrained_port, end_time - start_time)) |
| # Build constrained URL. Only pass on the file parameter. |
| - constrained_url = '%s?f=%s' % ( |
| + constrained_url = '%s?f=%s&no_cache=%s' % ( |
| cherrypy.url().replace( |
| ':%d' % self._options.port, ':%d' % constrained_port), |
| - f) |
| + f, |
| + no_cache) |
| # Redirect request to the constrained port. |
| cherrypy.lib.cptools.redirect(constrained_url, internal=False) |