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..fd3acc713346f2ca0e45de07f514b9ac96954299 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: |
| @@ -247,10 +254,12 @@ class ConstrainedNetworkServer(object): |
| (constrained_port, end_time - start_time)) |
| # Build constrained URL. Only pass on the file parameter. |
|
DaleCurtis
2012/04/19 19:42:10
Update comment.
shadi
2012/04/20 00:17:47
Done.
|
| - constrained_url = '%s?f=%s' % ( |
| + 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) |