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
bd1bf867
Commit
bd1bf867
authored
Apr 22, 2010
by
Denis Bilenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add test__server_http.py
parent
d0b0511d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
0 deletions
+62
-0
greentest/test__server_http.py
greentest/test__server_http.py
+62
-0
No files found.
greentest/test__server_http.py
0 → 100644
View file @
bd1bf867
import
unittest
import
gevent
from
gevent
import
http
import
test__server
from
test__server
import
*
internal_error
=
'''HTTP/1.0 500 Internal Server Error
Connection: close
Content-type: text/plain
Content-length: 21
Internal Server Error'''
.
replace
(
'
\
n
'
,
'
\
r
\
n
'
)
internal_error503
=
'''HTTP/1.0 503 Service Unavailable
Connection: close
Content-type: text/plain
Content-length: 31
Service Temporarily Unavailable'''
.
replace
(
'
\
n
'
,
'
\
r
\
n
'
)
class
SimpleHTTPServer
(
http
.
HTTPServer
):
def
handle
(
self
,
request
):
if
request
.
uri
==
'/ping'
:
request
.
send_reply
(
200
,
"OK"
,
"PONG"
)
elif
request
.
uri
==
'/long'
:
request
.
send_reply_start
(
200
,
"OK"
)
request
.
send_reply_chunk
(
"hello"
)
while
request
:
print
request
gevent
.
sleep
(
0.01
)
else
:
request
.
send_reply
(
404
,
"what?"
,
""
)
class
Settings
:
ServerClass
=
http
.
HTTPServer
ServerSubClass
=
SimpleHTTPServer
restartable
=
False
@
staticmethod
def
assert500
(
self
):
conn
=
self
.
makefile
()
conn
.
write
(
'GET / HTTP/1.0
\
r
\
n
\
r
\
n
'
)
result
=
conn
.
read
()
assert
result
==
internal_error
,
(
result
,
internal_error
)
@
staticmethod
def
assert503
(
self
):
conn
=
self
.
makefile
()
conn
.
write
(
'GET / HTTP/1.0
\
r
\
n
\
r
\
n
'
)
result
=
conn
.
read
()
assert
result
==
internal_error503
,
(
result
,
internal_error503
)
test__server
.
Settings
=
Settings
if
__name__
==
'__main__'
:
unittest
.
main
()
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