~osomon/oxide/ensure-files-exist

« back to all changes in this revision

Viewing changes to qt/tests/qmltests/api/clear-test-cookies-hack.py

  • Committer: Olivier Tilloy
  • Date: 2014-09-25 16:27:09 UTC
  • mfrom: (677.1.95 oxide)
  • Revision ID: olivier.tilloy@canonical.com-20140925162709-h8bai0f1nfaf7cfy
Merge the latest changes from trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
from cStringIO import StringIO
2
 
 
3
 
# FIXME(chrisccoulson): We desperately need an API for clearing site data
4
 
# (not just cookies). This abomination is for ensuring there are no test
5
 
# cookies left from a previous test. Yeah, it sucks....
6
 
 
7
 
def handler(request):
8
 
  html = StringIO()
9
 
  html.write("<html></html>")
10
 
 
11
 
  request.send_response(200)
12
 
  request.send_header("Content-type", "text/html")
13
 
  request.send_header("Content-Length", html.tell())
14
 
  request.send_header("Cache-Control", "no-cache")
15
 
 
16
 
  if "Cookie" in request.headers:
17
 
    cookies = request.headers["Cookie"].split(";")
18
 
    for cookie in cookies:
19
 
      request.send_header("Set-Cookie", "%s=deleted;Expires=Thu, 01-01-1970 00-00-00 GMT;Domain=;Path=/" % cookie.split("=")[0])
20
 
 
21
 
  request.end_headers()
22
 
 
23
 
  request.wfile.write(html.getvalue())