Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
shrapnel
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
shrapnel
Commits
08a101b1
Commit
08a101b1
authored
May 10, 2012
by
Sam Rushing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
check the syntax of the HTTP response
Bad_Response: new exception
parent
af8d4083
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
1 deletion
+14
-1
coro/http/client.py
coro/http/client.py
+14
-1
No files found.
coro/http/client.py
View file @
08a101b1
# -*- Mode: Python -*-
import
re
import
coro
import
coro.read_stream
from
protocol
import
http_file
,
header_set
,
latch
...
...
@@ -9,6 +10,9 @@ W = coro.write_stderr
class
HTTP_Protocol_Error
(
Exception
):
pass
class
Bad_Response
(
HTTP_Protocol_Error
):
pass
# viewed at its core, HTTP is a two-way exchange of messages,
# some of which may have content associated with them.
...
...
@@ -63,8 +67,17 @@ class client:
else
:
req
.
wake
()
response_re
=
re
.
compile
(
'([^ ]+) ([0-9][0-9][0-9])'
)
def
_read_message
(
self
,
req
):
req
.
response
=
self
.
stream
.
read_line
()[:
-
2
]
line
=
self
.
stream
.
read_line
()
if
not
line
:
raise
HTTP_Protocol_Error
(
'unexpected close'
)
req
.
response
=
line
[:
-
2
]
m
=
self
.
response_re
.
match
(
req
.
response
)
if
not
m
:
raise
Bad_Response
(
req
.
response
)
else
:
req
.
version
,
req
.
reply_code
=
m
.
groups
()
lines
=
[]
while
1
:
line
=
self
.
stream
.
read_line
()
...
...
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