diff options
author | ipknHama <ipknhama@gmail.com> | 2014-08-08 03:53:36 +0900 |
---|---|---|
committer | ipknHama <ipknhama@gmail.com> | 2014-08-08 03:53:36 +0900 |
commit | 3018ff063acb747065adea877e3e2ac9423f5233 (patch) | |
tree | 110f1a6596242b7837c16f88b4838d6fd93dc93c /examples/example_test.py | |
parent | a0c93f5b84cc11b30bc6320ac26127832ef8bf7a (diff) | |
parent | 001c66b378d200bdecc8a4a692c5a73a7d426b8f (diff) | |
download | crow-3018ff063acb747065adea877e3e2ac9423f5233.tar.gz crow-3018ff063acb747065adea877e3e2ac9423f5233.zip |
Merge branch 'directory-restructuring'
Directory structure changed.
Crow becomes a complete header-only library with http_parser_merged.h.
Provides amalgamated crow_all.h (all feature in one header file).
Diffstat (limited to 'examples/example_test.py')
-rw-r--r-- | examples/example_test.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/examples/example_test.py b/examples/example_test.py new file mode 100644 index 0000000..e2bf651 --- /dev/null +++ b/examples/example_test.py @@ -0,0 +1,28 @@ +import urllib +assert "Hello World!" == urllib.urlopen('http://localhost:18080').read() +assert "About Crow example." == urllib.urlopen('http://localhost:18080/about').read() +assert 404 == urllib.urlopen('http://localhost:18080/list').getcode() +assert "3 bottles of beer!" == urllib.urlopen('http://localhost:18080/hello/3').read() +assert "100 bottles of beer!" == urllib.urlopen('http://localhost:18080/hello/100').read() +assert 400 == urllib.urlopen('http://localhost:18080/hello/500').getcode() +assert "3" == urllib.urlopen('http://localhost:18080/add_json', data='{"a":1,"b":2}').read() +assert "3" == urllib.urlopen('http://localhost:18080/add/1/2').read() + +# test persistent connection +import socket +import time +s = socket.socket() +s.connect(('localhost', 18080)) +for i in xrange(10): + s.send('''GET / HTTP/1.1 +Host: localhost\r\n\r\n'''); + assert 'Hello World!' in s.recv(1024) + +# test timeout +s = socket.socket() +s.connect(('localhost', 18080)) +print 'ERROR REQUEST' +s.send('''GET / HTTP/1.1 +hHhHHefhwjkefhklwejfklwejf +''') +print s.recv(1024) |