Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gevent
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gevent
Commits
099d4e4e
Commit
099d4e4e
authored
Jan 22, 2010
by
Denis Bilenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wsgi_test.py: do not use deprecated connect_tcp
parent
4c9f2068
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
16 deletions
+19
-16
greentest/wsgi_test.py
greentest/wsgi_test.py
+19
-16
No files found.
greentest/wsgi_test.py
View file @
099d4e4e
...
...
@@ -119,6 +119,9 @@ class TestCase(greentest.TestCase):
timeout
.
cancel
()
# XXX currently listening socket is kept open in gevent.wsgi
def
connect
(
self
):
return
socket
.
create_connection
((
'127.0.0.1'
,
self
.
port
))
class
TestHttpdBasic
(
TestCase
):
...
...
@@ -133,7 +136,7 @@ class TestHttpdBasic(TestCase):
return
[
"not found"
]
def
test_001_server
(
self
):
sock
=
s
ocket
.
connect_tcp
((
'127.0.0.1'
,
self
.
port
)
)
sock
=
s
elf
.
connect
(
)
sock
.
sendall
(
'GET / HTTP/1.1
\
r
\
n
Host: localhost
\
r
\
n
Connection: close
\
r
\
n
\
r
\
n
'
)
result
=
sock
.
makefile
().
read
()
sock
.
close
()
...
...
@@ -160,15 +163,15 @@ class TestHttpdBasic(TestCase):
def
test_003_passing_non_int_to_read
(
self
):
# This should go in greenio_test
fd
=
s
ocket
.
connect_tcp
((
'127.0.0.1'
,
self
.
port
)
).
makefile
(
bufsize
=
1
)
fd
=
s
elf
.
connect
(
).
makefile
(
bufsize
=
1
)
fd
.
write
(
'GET / HTTP/1.1
\
r
\
n
Host: localhost
\
r
\
n
\
r
\
n
'
)
cancel
=
gevent
.
Timeout
.
start_new
(
1
,
RuntimeError
)
self
.
assertRaises
(
TypeError
,
fd
.
read
,
"This shouldn't work"
)
cancel
.
cancel
()
fd
.
close
()
def
test_004_c
lose_keepaliv
e
(
self
):
fd
=
s
ocket
.
connect_tcp
((
'127.0.0.1'
,
self
.
port
)
).
makefile
(
bufsize
=
1
)
def
test_004_c
onnection_clos
e
(
self
):
fd
=
s
elf
.
connect
(
).
makefile
(
bufsize
=
1
)
fd
.
write
(
'GET / HTTP/1.1
\
r
\
n
Host: localhost
\
r
\
n
\
r
\
n
'
)
read_http
(
fd
)
fd
.
write
(
'GET / HTTP/1.1
\
r
\
n
Host: localhost
\
r
\
n
Connection: close
\
r
\
n
\
r
\
n
'
)
...
...
@@ -186,7 +189,7 @@ class TestHttpdBasic(TestCase):
print
out
.
read
()
def
SKIP_test_006_reject_long_urls
(
self
):
fd
=
s
ocket
.
connect_tcp
((
'127.0.0.1'
,
self
.
port
)
).
makefile
(
bufsize
=
1
)
fd
=
s
elf
.
connect
(
).
makefile
(
bufsize
=
1
)
path_parts
=
[]
for
ii
in
range
(
3000
):
path_parts
.
append
(
'path'
)
...
...
@@ -199,7 +202,7 @@ class TestHttpdBasic(TestCase):
fd
.
close
()
def
test_008_correctresponse
(
self
):
fd
=
s
ocket
.
connect_tcp
((
'127.0.0.1'
,
self
.
port
)
).
makefile
(
bufsize
=
1
)
fd
=
s
elf
.
connect
(
).
makefile
(
bufsize
=
1
)
fd
.
write
(
'GET / HTTP/1.1
\
r
\
n
Host: localhost
\
r
\
n
\
r
\
n
'
)
response_line_200
,
_
,
_
=
read_http
(
fd
)
fd
.
write
(
'GET /notexist HTTP/1.1
\
r
\
n
Host: localhost
\
r
\
n
\
r
\
n
'
)
...
...
@@ -252,7 +255,7 @@ class TestGetArg(TestCase):
def
test_007_get_arg
(
self
):
# define a new handler that does a get_arg as well as a read_body
fd
=
s
ocket
.
connect_tcp
((
'127.0.0.1'
,
self
.
port
)
).
makefile
(
bufsize
=
1
)
fd
=
s
elf
.
connect
(
).
makefile
(
bufsize
=
1
)
request
=
'
\
r
\
n
'
.
join
((
'POST / HTTP/1.0'
,
'Host: localhost'
,
...
...
@@ -278,12 +281,12 @@ class TestChunkedApp(TestCase):
yield
"chunked"
def
test_009_chunked_response
(
self
):
fd
=
s
ocket
.
connect_tcp
((
'127.0.0.1'
,
self
.
port
)
).
makefile
(
bufsize
=
1
)
fd
=
s
elf
.
connect
(
).
makefile
(
bufsize
=
1
)
fd
.
write
(
'GET / HTTP/1.1
\
r
\
n
Host: localhost
\
r
\
n
Connection: close
\
r
\
n
\
r
\
n
'
)
self
.
assert_
(
'Transfer-Encoding: chunked'
in
fd
.
read
())
def
test_010_no_chunked_http_1_0
(
self
):
fd
=
s
ocket
.
connect_tcp
((
'127.0.0.1'
,
self
.
port
)
).
makefile
(
bufsize
=
1
)
fd
=
s
elf
.
connect
(
).
makefile
(
bufsize
=
1
)
fd
.
write
(
'GET / HTTP/1.0
\
r
\
n
Host: localhost
\
r
\
n
Connection: close
\
r
\
n
\
r
\
n
'
)
self
.
assert_
(
'Transfer-Encoding: chunked'
not
in
fd
.
read
())
...
...
@@ -299,7 +302,7 @@ class TestBigChunks(TestCase):
def
test_011_multiple_chunks
(
self
):
fd
=
s
ocket
.
connect_tcp
((
'127.0.0.1'
,
self
.
port
)
).
makefile
(
bufsize
=
1
)
fd
=
s
elf
.
connect
(
).
makefile
(
bufsize
=
1
)
fd
.
write
(
'GET / HTTP/1.1
\
r
\
n
Host: localhost
\
r
\
n
Connection: close
\
r
\
n
\
r
\
n
'
)
_
,
headers
=
read_headers
(
fd
)
assert
(
'Transfer-Encoding'
,
'chunked'
)
in
headers
.
items
(),
headers
...
...
@@ -327,21 +330,21 @@ class TestChunkedPost(TestCase):
return
[
x
for
x
in
iter
(
lambda
:
env
[
'wsgi.input'
].
read
(
1
),
''
)]
def
test_014_chunked_post
(
self
):
fd
=
s
ocket
.
connect_tcp
((
'127.0.0.1'
,
self
.
port
)
).
makefile
(
bufsize
=
1
)
fd
=
s
elf
.
connect
(
).
makefile
(
bufsize
=
1
)
fd
.
write
(
'POST /a HTTP/1.1
\
r
\
n
Host: localhost
\
r
\
n
Connection: close
\
r
\
n
'
'Transfer-Encoding: chunked
\
r
\
n
\
r
\
n
'
'2
\
r
\
n
oh
\
r
\
n
4
\
r
\
n
hai
\
r
\
n
0
\
r
\
n
\
r
\
n
'
)
response_line
,
headers
,
body
=
read_http
(
fd
)
self
.
assert_
(
body
==
'oh hai'
,
'invalid response %r'
%
body
)
fd
=
s
ocket
.
connect_tcp
((
'127.0.0.1'
,
self
.
port
)
).
makefile
(
bufsize
=
1
)
fd
=
s
elf
.
connect
(
).
makefile
(
bufsize
=
1
)
fd
.
write
(
'POST /b HTTP/1.1
\
r
\
n
Host: localhost
\
r
\
n
Connection: close
\
r
\
n
'
'Transfer-Encoding: chunked
\
r
\
n
\
r
\
n
'
'2
\
r
\
n
oh
\
r
\
n
4
\
r
\
n
hai
\
r
\
n
0
\
r
\
n
\
r
\
n
'
)
response_line
,
headers
,
body
=
read_http
(
fd
)
self
.
assert_
(
body
==
'oh hai'
,
'invalid response %r'
%
body
)
fd
=
s
ocket
.
connect_tcp
((
'127.0.0.1'
,
self
.
port
)
).
makefile
(
bufsize
=
1
)
fd
=
s
elf
.
connect
(
).
makefile
(
bufsize
=
1
)
fd
.
write
(
'POST /c HTTP/1.1
\
r
\
n
Host: localhost
\
r
\
n
Connection: close
\
r
\
n
'
'Transfer-Encoding: chunked
\
r
\
n
\
r
\
n
'
'2
\
r
\
n
oh
\
r
\
n
4
\
r
\
n
hai
\
r
\
n
0
\
r
\
n
\
r
\
n
'
)
...
...
@@ -363,12 +366,12 @@ class TestUseWrite(TestCase):
return
[]
def
test_015_write
(
self
):
fd
=
s
ocket
.
connect_tcp
((
'127.0.0.1'
,
self
.
port
)
).
makefile
(
bufsize
=
1
)
fd
=
s
elf
.
connect
(
).
makefile
(
bufsize
=
1
)
fd
.
write
(
'GET /a HTTP/1.1
\
r
\
n
Host: localhost
\
r
\
n
Connection: close
\
r
\
n
\
r
\
n
'
)
response_line
,
headers
,
body
=
read_http
(
fd
)
self
.
assert_
(
'Content-Length'
in
headers
)
fd
=
s
ocket
.
connect_tcp
((
'127.0.0.1'
,
self
.
port
)
).
makefile
(
bufsize
=
1
)
fd
=
s
elf
.
connect
(
).
makefile
(
bufsize
=
1
)
fd
.
write
(
'GET /b HTTP/1.1
\
r
\
n
Host: localhost
\
r
\
n
Connection: close
\
r
\
n
\
r
\
n
'
)
response_line
,
headers
,
body
=
read_http
(
fd
)
#self.assert_('Transfer-Encoding' in headers)
...
...
@@ -425,7 +428,7 @@ class TestInternational(TestCase):
return
[]
def
test
(
self
):
sock
=
s
ocket
.
connect_tcp
((
'127.0.0.1'
,
self
.
port
)
)
sock
=
s
elf
.
connect
(
)
sock
.
sendall
(
'GET /%D0%BF%D1%80%D0%B8%D0%B2%D0%B5%D1%82?%D0%B2%D0%BE%D0%BF%D1%80%D0%BE%D1%81=%D0%BE%D1%82%D0%B2%D0%B5%D1%82 HTTP/1.1
\
r
\
n
Host: localhost
\
r
\
n
Connection: close
\
r
\
n
\
r
\
n
'
)
result
=
sock
.
makefile
().
read
()
assert
'200 PASSED'
in
result
,
result
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment