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
fd7dc336
Commit
fd7dc336
authored
Mar 02, 2014
by
Sergey Lyubka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
unbroke unit test
parent
9c22771a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
16 deletions
+14
-16
unit_test.c
examples/unit_test.c
+9
-8
mongoose.c
mongoose.c
+5
-8
No files found.
examples/unit_test.c
View file @
fd7dc336
...
...
@@ -377,13 +377,14 @@ static int ts2(struct mg_connection *conn) {
static
const
char
*
test_server
(
void
)
{
char
buf1
[
100
]
=
""
,
buf2
[
100
]
=
""
;
struct
mg_server
*
server
=
mg_create_server
((
void
*
)
"foo"
,
evh1
);
struct
mg_connection
*
conn
;
ASSERT
(
server
!=
NULL
);
ASSERT
(
mg_set_option
(
server
,
"listening_port"
,
LISTENING_ADDR
)
==
NULL
);
ASSERT
(
mg_set_option
(
server
,
"document_root"
,
"."
)
==
NULL
);
ASSERT
(
mg_connect
(
server
,
"127.0.0.1"
,
atoi
(
HTTP_PORT
),
0
,
buf1
)
==
1
);
ASSERT
(
mg_connect
(
server
,
"127.0.0.1"
,
atoi
(
HTTP_PORT
),
0
,
buf2
)
==
1
);
ASSERT
(
(
conn
=
mg_connect
(
server
,
"127.0.0.1"
,
atoi
(
HTTP_PORT
),
0
))
!=
NULL
);
ASSERT
(
(
conn
=
mg_connect
(
server
,
"127.0.0.1"
,
atoi
(
HTTP_PORT
),
0
))
!=
NULL
);
{
int
i
;
for
(
i
=
0
;
i
<
50
;
i
++
)
mg_poll_server
(
server
,
1
);
}
ASSERT
(
strcmp
(
buf1
,
"foo ? 127.0.0.1"
)
==
0
);
...
...
@@ -460,13 +461,14 @@ static int cb3(struct mg_connection *conn) {
static
const
char
*
test_mg_connect
(
void
)
{
char
buf2
[
40
]
=
""
,
buf3
[
40
]
=
""
,
buf4
[
40
]
=
""
;
struct
mg_server
*
server
=
mg_create_server
(
NULL
,
NULL
);
// cb4h
struct
mg_connection
*
conn
;
ASSERT
(
mg_set_option
(
server
,
"listening_port"
,
LISTENING_ADDR
)
==
NULL
);
ASSERT
(
mg_set_option
(
server
,
"document_root"
,
"."
)
==
NULL
);
ASSERT
(
mg_connect
(
server
,
""
,
0
,
0
,
NULL
,
NULL
)
==
0
);
ASSERT
(
mg_connect
(
server
,
"127.0.0.1"
,
atoi
(
HTTP_PORT
),
0
,
buf2
)
==
1
);
ASSERT
(
mg_connect
(
server
,
"127.0.0.1"
,
29
,
0
,
cb3
,
buf3
)
==
1
);
ASSERT
(
mg_connect
(
server
,
"127.0.0.1"
,
atoi
(
HTTP_PORT
),
0
,
buf4
)
==
1
);
ASSERT
(
mg_connect
(
server
,
""
,
0
,
0
)
==
NULL
);
ASSERT
(
(
conn
=
mg_connect
(
server
,
"127.0.0.1"
,
atoi
(
HTTP_PORT
),
0
))
!=
NULL
);
ASSERT
(
(
conn
=
mg_connect
(
server
,
"127.0.0.1"
,
29
,
0
))
!=
NULL
);
ASSERT
(
(
conn
=
mg_connect
(
server
,
"127.0.0.1"
,
atoi
(
HTTP_PORT
),
0
))
!=
NULL
);
{
int
i
;
for
(
i
=
0
;
i
<
50
;
i
++
)
mg_poll_server
(
server
,
1
);
}
...
...
@@ -572,8 +574,7 @@ static const char *test_rewrites(void) {
ASSERT
(
mg_set_option
(
server
,
"url_rewrites"
,
"/xx=./mongoose.h"
)
==
NULL
);
ASSERT
(
mg_connect
(
server
,
"127.0.0.1"
,
atoi
(
mg_get_option
(
server
,
"listening_port"
)),
0
,
us1
,
buf1
)
==
1
);
atoi
(
mg_get_option
(
server
,
"listening_port"
)),
0
)
!=
NULL
);
{
int
i
;
for
(
i
=
0
;
i
<
50
;
i
++
)
mg_poll_server
(
server
,
1
);
}
//printf("[%s]\n", buf1);
...
...
mongoose.c
View file @
fd7dc336
...
...
@@ -4139,7 +4139,7 @@ static void call_http_client_handler(struct connection *conn, int code) {
conn
->
mg_conn
.
content_len
=
conn
->
ns_conn
->
recv_iobuf
.
len
;
}
conn
->
mg_conn
.
content
=
conn
->
ns_conn
->
recv_iobuf
.
buf
;
if
(
call_user
(
conn
,
-
1
)
||
code
==
MG_CONNECT_FAILURE
||
if
(
call_user
(
conn
,
MG_CONNECT
)
||
code
==
MG_CONNECT_FAILURE
||
code
==
MG_DOWNLOAD_FAILURE
)
{
conn
->
ns_conn
->
flags
|=
NSF_CLOSE_IMMEDIATELY
;
}
...
...
@@ -4553,13 +4553,10 @@ static void mg_ev_handler(struct ns_connection *nc, enum ns_event ev, void *p) {
break
;
case
NS_CONNECT
:
{
int
ok
=
*
(
int
*
)
p
;
conn
->
mg_conn
.
status_code
=
ok
==
0
?
MG_CONNECT_SUCCESS
:
MG_CONNECT_FAILURE
;
if
(
call_user
(
conn
,
MG_CONNECT
)
!=
0
||
ok
!=
0
)
{
nc
->
flags
|=
NSF_CLOSE_IMMEDIATELY
;
}
conn
->
mg_conn
.
status_code
=
*
(
int
*
)
p
;
if
(
conn
->
mg_conn
.
status_code
!=
0
||
call_user
(
conn
,
MG_CONNECT
)
==
MG_FALSE
)
{
nc
->
flags
|=
NSF_CLOSE_IMMEDIATELY
;
}
break
;
...
...
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