Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
caucase
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
caucase
Commits
948d3f16
Commit
948d3f16
authored
Oct 25, 2017
by
Vincent Pelletier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
http: Add support for Expect:100-continue request header.
parent
acc11f04
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
0 deletions
+31
-0
caucase/http_wsgibase.py
caucase/http_wsgibase.py
+31
-0
No files found.
caucase/http_wsgibase.py
View file @
948d3f16
...
@@ -72,9 +72,24 @@ class ChunkedFile(ProxyFile):
...
@@ -72,9 +72,24 @@ class ChunkedFile(ProxyFile):
self
.
_recv_buf
=
result
[
length
:]
self
.
_recv_buf
=
result
[
length
:]
return
result
[:
length
]
return
result
[:
length
]
class
HookFirstReadFile
(
ProxyFile
):
"""
Trigger a callable on first read.
"""
def
__init__
(
self
,
actual_file
,
on_first_read
):
super
(
HookFirstReadFile
,
self
).
__init__
(
actual_file
)
self
.
_on_first_read
=
on_first_read
self
.
read
=
self
.
_read_hook
def
_read_hook
(
self
,
*
args
,
**
kw
):
self
.
_on_first_read
()
del
self
.
read
return
self
.
read
(
*
args
,
**
kw
)
class
CleanServerHandler
(
ServerHandler
):
class
CleanServerHandler
(
ServerHandler
):
"""
"""
- Handle chunked transfer encoding.
- Handle chunked transfer encoding.
- Handle expect/continue protocol.
- Do not include OS environment variables in each request's WSGI environment.
- Do not include OS environment variables in each request's WSGI environment.
Seriously, what the fsck, python ?
Seriously, what the fsck, python ?
"""
"""
...
@@ -97,3 +112,19 @@ class CleanServerHandler(ServerHandler):
...
@@ -97,3 +112,19 @@ class CleanServerHandler(ServerHandler):
# We handle this, hide it from Application
# We handle this, hide it from Application
del
environ
[
'HTTP_TRANSFER_ENCODING'
]
del
environ
[
'HTTP_TRANSFER_ENCODING'
]
environ
[
'wsgi.input'
]
=
ChunkedFile
(
environ
[
'wsgi.input'
])
environ
[
'wsgi.input'
]
=
ChunkedFile
(
environ
[
'wsgi.input'
])
if
environ
.
get
(
'HTTP_EXPECT'
,
''
).
lower
()
==
'100-continue'
:
# We handle this, hide it from Application
del
environ
[
'HTTP_EXPECT'
]
environ
[
'wsgi.input'
]
=
HookFirstReadFile
(
environ
[
'wsgi.input'
],
self
.
_100_continue
,
)
def
_100_continue
(
self
):
"""
Emit "100 Continue" intermediate response.
"""
self
.
_write
(
'HTTP/%s 100 Continue
\
r
\
n
\
r
\
n
'
%
(
self
.
http_version
,
))
self
.
_flush
()
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