Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongoose
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
esp
mongoose
Commits
87d841d8
Commit
87d841d8
authored
Oct 01, 2013
by
Sergey Lyubka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Set content_len to 0 for GET requests without Content-Length header.
parent
5153eebc
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
4 deletions
+18
-4
mongoose.c
build/src/mongoose.c
+9
-2
mongoose.c
mongoose.c
+9
-2
No files found.
build/src/mongoose.c
View file @
87d841d8
...
@@ -3643,9 +3643,16 @@ static int getreq(struct mg_connection *conn, char *ebuf, size_t ebuf_len) {
...
@@ -3643,9 +3643,16 @@ static int getreq(struct mg_connection *conn, char *ebuf, size_t ebuf_len) {
snprintf
(
ebuf
,
ebuf_len
,
"Bad request: [%.*s]"
,
conn
->
data_len
,
conn
->
buf
);
snprintf
(
ebuf
,
ebuf_len
,
"Bad request: [%.*s]"
,
conn
->
data_len
,
conn
->
buf
);
}
else
{
}
else
{
// Request is valid. Set content_len attribute by parsing Content-Length
// Request is valid. Set content_len attribute by parsing Content-Length
// If Content-Length is absent, instruct mg_read() to read from the socket
// If Content-Length is absent, set content_len to 0 if request is GET,
// until socket is closed.
// and set it to INT64_MAX otherwise. Setting to INT64_MAX instructs
// mg_read() to read from the socket until socket is closed.
// The reason for treating GET and POST/PUT differently is that libraries
// like jquery do not set Content-Length in GET requests, and we don't
// want mg_read() to hang waiting until socket is timed out.
conn
->
content_len
=
INT64_MAX
;
conn
->
content_len
=
INT64_MAX
;
if
(
!
mg_strcasecmp
(
conn
->
request_info
.
request_method
,
"GET"
))
{
conn
->
content_len
=
0
;
}
if
((
cl
=
get_header
(
&
conn
->
request_info
,
"Content-Length"
))
!=
NULL
)
{
if
((
cl
=
get_header
(
&
conn
->
request_info
,
"Content-Length"
))
!=
NULL
)
{
conn
->
content_len
=
strtoll
(
cl
,
NULL
,
10
);
conn
->
content_len
=
strtoll
(
cl
,
NULL
,
10
);
}
}
...
...
mongoose.c
View file @
87d841d8
...
@@ -4954,9 +4954,16 @@ static int getreq(struct mg_connection *conn, char *ebuf, size_t ebuf_len) {
...
@@ -4954,9 +4954,16 @@ static int getreq(struct mg_connection *conn, char *ebuf, size_t ebuf_len) {
snprintf
(
ebuf
,
ebuf_len
,
"Bad request: [%.*s]"
,
conn
->
data_len
,
conn
->
buf
);
snprintf
(
ebuf
,
ebuf_len
,
"Bad request: [%.*s]"
,
conn
->
data_len
,
conn
->
buf
);
}
else
{
}
else
{
// Request is valid. Set content_len attribute by parsing Content-Length
// Request is valid. Set content_len attribute by parsing Content-Length
// By default, in the absence of Content-Length, instruct mg_read()
// If Content-Length is absent, set content_len to 0 if request is GET,
// to read from the socket until the socket is closed.
// and set it to INT64_MAX otherwise. Setting to INT64_MAX instructs
// mg_read() to read from the socket until socket is closed.
// The reason for treating GET and POST/PUT differently is that libraries
// like jquery do not set Content-Length in GET requests, and we don't
// want mg_read() to hang waiting until socket is timed out.
conn
->
content_len
=
INT64_MAX
;
conn
->
content_len
=
INT64_MAX
;
if
(
!
mg_strcasecmp
(
conn
->
request_info
.
request_method
,
"GET"
))
{
conn
->
content_len
=
0
;
}
if
((
cl
=
get_header
(
&
conn
->
request_info
,
"Content-Length"
))
!=
NULL
)
{
if
((
cl
=
get_header
(
&
conn
->
request_info
,
"Content-Length"
))
!=
NULL
)
{
conn
->
content_len
=
strtoll
(
cl
,
NULL
,
10
);
conn
->
content_len
=
strtoll
(
cl
,
NULL
,
10
);
}
}
...
...
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