Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
snf-ganeti
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
itminedu
snf-ganeti
Commits
64357ed8
Commit
64357ed8
authored
16 years ago
by
Michael Hanselmann
Browse files
Options
Downloads
Patches
Plain Diff
ganeti.http: Use 411 Length Required in server code
Reviewed-by: iustinp
parent
cd4d138f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/http.py
+18
-3
18 additions, 3 deletions
lib/http.py
with
18 additions
and
3 deletions
lib/http.py
+
18
−
3
View file @
64357ed8
...
...
@@ -440,17 +440,32 @@ class _HttpConnectionHandler(object):
def
_ReadPostData
(
self
):
"""
Reads POST/PUT data
Quoting RFC1945, section 7.2 (HTTP/1.0):
"
The presence of an entity body in
a request is signaled by the inclusion of a Content-Length header field in
the request message headers. HTTP/1.0 requests containing an entity body
must include a valid Content-Length header field.
"
"""
# While not according to specification, we only support an entity body for
# POST and PUT.
if
(
not
self
.
request_method
or
self
.
request_method
.
upper
()
not
in
(
HTTP_POST
,
HTTP_PUT
)):
self
.
request_post_data
=
None
return
# TODO: Decide what to do when C
ontent
-L
ength
header was not sent
c
ontent
_l
ength
=
None
try
:
content_length
=
int
(
self
.
request_headers
.
get
(
'
Content-Length
'
,
0
))
if
HTTP_CONTENT_LENGTH
in
self
.
request_headers
:
content_length
=
int
(
self
.
request_headers
[
HTTP_CONTENT_LENGTH
])
except
TypeError
:
pass
except
ValueError
:
raise
HTTPBadRequest
(
"
No Content-Length header or invalid format
"
)
pass
# 411 Length Required is specified in RFC2616, section 10.4.12 (HTTP/1.1)
if
content_length
is
None
:
raise
HTTPLengthRequired
(
"
Missing Content-Length header or
"
"
invalid format
"
)
data
=
self
.
rfile
.
read
(
content_length
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment