Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
mongoose
Commits
93c5335d
Commit
93c5335d
authored
Jan 23, 2014
by
Sergey Lyubka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
USE_POST_SIZE_LIMIT -> MONGOOSE_USE_POST_SIZE_LIMIT, and unit test added
parent
192205b1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
5 deletions
+24
-5
mongoose.c
mongoose.c
+3
-4
unit_test.c
unit_test.c
+21
-1
No files found.
mongoose.c
View file @
93c5335d
...
@@ -675,9 +675,8 @@ static void send_http_error(struct connection *conn, int code,
...
@@ -675,9 +675,8 @@ static void send_http_error(struct connection *conn, int code,
body_len
=
mg_snprintf
(
body
,
sizeof
(
body
),
"%d %s
\n
"
,
code
,
message
);
body_len
=
mg_snprintf
(
body
,
sizeof
(
body
),
"%d %s
\n
"
,
code
,
message
);
if
(
fmt
!=
NULL
)
{
if
(
fmt
!=
NULL
)
{
body
[
body_len
++
]
=
'\n'
;
va_start
(
ap
,
fmt
);
va_start
(
ap
,
fmt
);
body_len
+=
mg_snprintf
(
body
+
body_len
,
sizeof
(
body
)
-
body_len
,
fmt
,
ap
);
body_len
+=
mg_
v
snprintf
(
body
+
body_len
,
sizeof
(
body
)
-
body_len
,
fmt
,
ap
);
va_end
(
ap
);
va_end
(
ap
);
}
}
if
(
code
>=
300
&&
code
<=
399
)
{
if
(
code
>=
300
&&
code
<=
399
)
{
...
@@ -3358,9 +3357,9 @@ static void open_local_endpoint(struct connection *conn) {
...
@@ -3358,9 +3357,9 @@ static void open_local_endpoint(struct connection *conn) {
{
{
const
char
*
cl
=
mg_get_header
(
&
conn
->
mg_conn
,
"Content-Length"
);
const
char
*
cl
=
mg_get_header
(
&
conn
->
mg_conn
,
"Content-Length"
);
if
(
!
strcmp
(
conn
->
mg_conn
.
request_method
,
"POST"
)
&&
if
(
!
strcmp
(
conn
->
mg_conn
.
request_method
,
"POST"
)
&&
(
cl
==
NULL
||
to64
(
cl
)
>
USE_POST_SIZE_LIMIT
))
{
(
cl
==
NULL
||
to64
(
cl
)
>
MONGOOSE_
USE_POST_SIZE_LIMIT
))
{
send_http_error
(
conn
,
500
,
"POST size > %zu"
,
send_http_error
(
conn
,
500
,
"POST size > %zu"
,
(
size_t
)
USE_POST_SIZE_LIMIT
);
(
size_t
)
MONGOOSE_
USE_POST_SIZE_LIMIT
);
}
}
}
}
#endif
#endif
...
...
unit_test.c
View file @
93c5335d
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
#define MONGOOSE_USE_IPV6
#define MONGOOSE_USE_IPV6
#define MONGOOSE_USE_SSL
#define MONGOOSE_USE_SSL
#endif
#endif
#define MONGOOSE_USE_POST_SIZE_LIMIT 999
// USE_* definitions must be made before #include "mongoose.c" !
// USE_* definitions must be made before #include "mongoose.c" !
#include "mongoose.c"
#include "mongoose.c"
...
@@ -456,25 +457,44 @@ static int cb2(struct mg_connection *conn) {
...
@@ -456,25 +457,44 @@ static int cb2(struct mg_connection *conn) {
return
ret_val
;
return
ret_val
;
}
}
static
int
cb4h
(
struct
mg_connection
*
conn
)
{
mg_send_data
(
conn
,
":-)"
,
3
);
return
MG_REPLY_COMPLETED
;
}
static
int
cb4
(
struct
mg_connection
*
conn
)
{
if
(
conn
->
status_code
==
MG_CONNECT_SUCCESS
)
{
mg_printf
(
conn
,
"%s"
,
"POST /x HTTP/1.0
\r\n
Content-Length: 999999
\r\n\r\n
"
);
return
MG_REPLY_TO_BE_CONTINUED
;
}
else
{
sprintf
((
char
*
)
conn
->
connection_param
,
"%.*s"
,
(
int
)
conn
->
content_len
,
conn
->
content
);
}
return
MG_REPLY_COMPLETED
;
}
static
int
cb3
(
struct
mg_connection
*
conn
)
{
static
int
cb3
(
struct
mg_connection
*
conn
)
{
sprintf
((
char
*
)
conn
->
connection_param
,
"%d"
,
conn
->
status_code
);
sprintf
((
char
*
)
conn
->
connection_param
,
"%d"
,
conn
->
status_code
);
return
1
;
return
1
;
}
}
static
const
char
*
test_mg_connect
(
void
)
{
static
const
char
*
test_mg_connect
(
void
)
{
char
buf2
[
40
]
=
""
,
buf3
[
40
]
=
""
;
char
buf2
[
40
]
=
""
,
buf3
[
40
]
=
""
,
buf4
[
40
]
=
""
;
struct
mg_server
*
server
=
mg_create_server
(
NULL
);
struct
mg_server
*
server
=
mg_create_server
(
NULL
);
ASSERT
(
mg_set_option
(
server
,
"listening_port"
,
LISTENING_ADDR
)
==
NULL
);
ASSERT
(
mg_set_option
(
server
,
"listening_port"
,
LISTENING_ADDR
)
==
NULL
);
ASSERT
(
mg_set_option
(
server
,
"document_root"
,
"."
)
==
NULL
);
ASSERT
(
mg_set_option
(
server
,
"document_root"
,
"."
)
==
NULL
);
mg_add_uri_handler
(
server
,
"/x"
,
cb4h
);
ASSERT
(
mg_connect
(
server
,
""
,
0
,
0
,
NULL
,
NULL
)
==
0
);
ASSERT
(
mg_connect
(
server
,
""
,
0
,
0
,
NULL
,
NULL
)
==
0
);
ASSERT
(
mg_connect
(
server
,
"127.0.0.1"
,
atoi
(
HTTP_PORT
),
0
,
cb2
,
buf2
)
==
1
);
ASSERT
(
mg_connect
(
server
,
"127.0.0.1"
,
atoi
(
HTTP_PORT
),
0
,
cb2
,
buf2
)
==
1
);
ASSERT
(
mg_connect
(
server
,
"127.0.0.1"
,
1
,
0
,
cb3
,
buf3
)
==
1
);
ASSERT
(
mg_connect
(
server
,
"127.0.0.1"
,
1
,
0
,
cb3
,
buf3
)
==
1
);
ASSERT
(
mg_connect
(
server
,
"127.0.0.1"
,
atoi
(
HTTP_PORT
),
0
,
cb4
,
buf4
)
==
1
);
{
int
i
;
for
(
i
=
0
;
i
<
50
;
i
++
)
mg_poll_server
(
server
,
0
);
}
{
int
i
;
for
(
i
=
0
;
i
<
50
;
i
++
)
mg_poll_server
(
server
,
0
);
}
ASSERT
(
strcmp
(
buf2
,
"add"
)
==
0
);
ASSERT
(
strcmp
(
buf2
,
"add"
)
==
0
);
ASSERT
(
strcmp
(
buf3
,
"1"
)
==
0
);
ASSERT
(
strcmp
(
buf3
,
"1"
)
==
0
);
ASSERT
(
strcmp
(
buf4
,
"500 Server Error
\n
POST size > 999"
)
==
0
);
mg_destroy_server
(
&
server
);
mg_destroy_server
(
&
server
);
return
NULL
;
return
NULL
;
...
...
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