forked from artyom-beilis/cppcms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcookie_test.py
More file actions
executable file
·43 lines (33 loc) · 1.07 KB
/
Copy pathcookie_test.py
File metadata and controls
executable file
·43 lines (33 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env python
# coding=utf-8
# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
import httplib
import sys
def check(name,A,B):
if A != B:
print "Error :" + name
print "-----Actual--"
print A,"---Expected--"
print B,"-------------"
f1=open('actual.txt','wb')
f2=open('expected.txt','wb')
f1.write(A)
f2.write(B)
f1.close()
f2.close()
sys.exit(1)
else:
print "Ok:"+name
class Nothing:
pass
def test_valid(headers,expected):
h=httplib.HTTPConnection('localhost:8080');
h.request('GET','/test','',{ 'Cookie': headers } );
r=h.getresponse()
check(headers,r.read(),expected)
test_valid('test=foo','test:foo\n')
test_valid('test=','test:\n')
test_valid('test','test:\n')
test_valid('test="\xD7\xA9\xD7\x9C\xD7\x95\xD7\x9D"; z=x','test:\xD7\xA9\xD7\x9C\xD7\x95\xD7\x9D\nz:x\n');
test_valid('test="\xD7\xA9\\"\xD7\x9C\xD7\x95\xD7\x9D"; z=x','test:\xD7\xA9"\xD7\x9C\xD7\x95\xD7\x9D\nz:x\n');
test_valid('a=\xD7\xA9\xD7\x9C\xD7\x95\xD7\x9D; z=x','z:x\n');