Gitweb links:

...log 
http://git.netsurf-browser.org/netsurf-test.git/shortlog/efd9e9f7c4948c58c6d48b8be76d33c5300dd2c2
...commit 
http://git.netsurf-browser.org/netsurf-test.git/commit/efd9e9f7c4948c58c6d48b8be76d33c5300dd2c2
...tree 
http://git.netsurf-browser.org/netsurf-test.git/tree/efd9e9f7c4948c58c6d48b8be76d33c5300dd2c2

The branch, master has been updated
       via  efd9e9f7c4948c58c6d48b8be76d33c5300dd2c2 (commit)
      from  29cf60c35fed623af09ea17b817cde93c479ee38 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commitdiff 
http://git.netsurf-browser.org/netsurf-test.git/commit/?id=efd9e9f7c4948c58c6d48b8be76d33c5300dd2c2
commit efd9e9f7c4948c58c6d48b8be76d33c5300dd2c2
Author: Daniel Silverstone <[email protected]>
Commit: Daniel Silverstone <[email protected]>

    CGI: Add a basic cookies CGI
    
    Signed-off-by: Daniel Silverstone <[email protected]>

diff --git a/cgi-bin/cookies.cgi b/cgi-bin/cookies.cgi
new file mode 100644
index 0000000..c8fe80a
--- /dev/null
+++ b/cgi-bin/cookies.cgi
@@ -0,0 +1,62 @@
+#!/usr/bin/python3
+
+import cgi
+import cgitb
+import os
+import sys
+import io
+import json
+
+cgitb.enable()
+
+cookies = {}
+
+if os.environ.has_key('HTTP_COOKIE'):
+   for cookie in map(str.strip, str.split(os.environ['HTTP_COOKIE'], ';')):
+      (key, value) = cookie.split('=')
+      cookies[key] = value
+
+print("Content-Type: text/html")
+print("")
+print("""
+<html>
+  <head><title>Cookie test</title></head>
+  <body>
+    <h1>Reflected cookies</h1>
+    <ul>
+""")
+
+for k, v in cookies.items():
+    print("      <li>{}: {}</li>".format(cgi.escape(k), cgi.escape(v)))
+print("""
+    </ul>
+    <hr />
+    <script>""")
+
+print("    var uploaded_cookies = {};".format(json.dumps(cookies)))
+print("""
+function getCookie(cname) {
+  var name = cname + "=";
+  var ca = document.cookie.split(';');
+  for(var i = 0; i < ca.length; i++) {
+    var c = ca[i];
+    while (c.charAt(0) == ' ') {
+      c = c.substring(1);
+    }
+    if (c.indexOf(name) == 0) {
+      return c.substring(name.length, c.length);
+    }
+  }
+  return "";
+}
+      var counter = getCookie("counter");
+      if (counter === "") { counter = "0"; }
+      var uploaded_counter = uploaded_cookies["counter"] || "0";
+      document.write("<b>Cookie:</b> " + counter + "<br/><b>JSON:</b> " + 
uploaded_counter + "<br />");
+      document.cookie = "counter=" + ((parseInt(counter) + 1).toString());
+    </script>
+  </body>
+</html>
+""")
+
+


-----------------------------------------------------------------------

Summary of changes:
 cgi-bin/cookies.cgi |   62 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 62 insertions(+)
 create mode 100644 cgi-bin/cookies.cgi

diff --git a/cgi-bin/cookies.cgi b/cgi-bin/cookies.cgi
new file mode 100644
index 0000000..c8fe80a
--- /dev/null
+++ b/cgi-bin/cookies.cgi
@@ -0,0 +1,62 @@
+#!/usr/bin/python3
+
+import cgi
+import cgitb
+import os
+import sys
+import io
+import json
+
+cgitb.enable()
+
+cookies = {}
+
+if os.environ.has_key('HTTP_COOKIE'):
+   for cookie in map(str.strip, str.split(os.environ['HTTP_COOKIE'], ';')):
+      (key, value) = cookie.split('=')
+      cookies[key] = value
+
+print("Content-Type: text/html")
+print("")
+print("""
+<html>
+  <head><title>Cookie test</title></head>
+  <body>
+    <h1>Reflected cookies</h1>
+    <ul>
+""")
+
+for k, v in cookies.items():
+    print("      <li>{}: {}</li>".format(cgi.escape(k), cgi.escape(v)))
+print("""
+    </ul>
+    <hr />
+    <script>""")
+
+print("    var uploaded_cookies = {};".format(json.dumps(cookies)))
+print("""
+function getCookie(cname) {
+  var name = cname + "=";
+  var ca = document.cookie.split(';');
+  for(var i = 0; i < ca.length; i++) {
+    var c = ca[i];
+    while (c.charAt(0) == ' ') {
+      c = c.substring(1);
+    }
+    if (c.indexOf(name) == 0) {
+      return c.substring(name.length, c.length);
+    }
+  }
+  return "";
+}
+      var counter = getCookie("counter");
+      if (counter === "") { counter = "0"; }
+      var uploaded_counter = uploaded_cookies["counter"] || "0";
+      document.write("<b>Cookie:</b> " + counter + "<br/><b>JSON:</b> " + 
uploaded_counter + "<br />");
+      document.cookie = "counter=" + ((parseInt(counter) + 1).toString());
+    </script>
+  </body>
+</html>
+""")
+
+


-- 
NetSurf test cases

_______________________________________________
netsurf-commits mailing list
[email protected]
http://listmaster.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org

Reply via email to