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
da75a62a
Commit
da75a62a
authored
Jul 27, 2012
by
Sergey Lyubka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More tests
parent
0b4676b7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
5 deletions
+17
-5
env.cgi
test/env.cgi
+1
-5
test.pl
test/test.pl
+5
-0
unit_test.c
test/unit_test.c
+11
-0
No files found.
test/env.cgi
View file @
da75a62a
...
...
@@ -21,8 +21,6 @@ foreach my $key (sort keys %in) {
print
"\n"
;
#sleep 10;
print
'CURRENT_DIR='
.
getcwd
()
.
"\n"
;
print
"</pre>\n"
;
...
...
@@ -43,8 +41,6 @@ my $stuff = <<EOP ;
</
form
>
EOP
system
(
'some shit'
);
#print STDERR "fuck!!!\n\n";
#system('some shit');
print
$stuff
;
test/test.pl
View file @
da75a62a
...
...
@@ -339,6 +339,11 @@ unless (scalar(@ARGV) > 0 and $ARGV[0] eq "basic_tests") {
o
(
"GET /hello.txt HTTP/1.0\nAuthorization: $auth_header\n\n"
,
'HTTP/1.1 200 OK'
,
'GET regular file with auth'
);
unlink
"$root/.htpasswd"
;
my
$x
=
'x='
.
'A'
x
(
200
*
1024
);
my
$len
=
length
(
$x
);
o
(
"POST /env.cgi HTTP/1.0\r\nContent-Length: $len\r\n\r\n$x"
,
'^HTTP/1.1 200 OK'
,
'Long POST'
);
o
(
"GET /env.cgi HTTP/1.0\n\r\n"
,
'HTTP/1.1 200 OK'
,
'GET CGI file'
);
o
(
"GET /bad2.cgi HTTP/1.0\n\n"
,
"HTTP/1.1 123 Please pass me to the client\r"
,
'CGI Status code text'
);
...
...
test/unit_test.c
View file @
da75a62a
...
...
@@ -11,6 +11,7 @@ static void test_parse_http_request() {
char
req1
[]
=
"GET / HTTP/1.1
\r\n\r\n
"
;
char
req2
[]
=
"BLAH / HTTP/1.1
\r\n\r\n
"
;
char
req3
[]
=
"GET / HTTP/1.1
\r\n
Bah
\r\n
"
;
char
req4
[]
=
"GET / HTTP/1.1
\r\n
A: foo bar
\r\n
B: bar
\r\n
baz
\r\n\r\n
"
;
ASSERT
(
parse_http_request
(
req1
,
&
ri
)
==
1
);
ASSERT
(
strcmp
(
ri
.
http_version
,
"1.1"
)
==
0
);
...
...
@@ -23,6 +24,16 @@ static void test_parse_http_request() {
ASSERT
(
ri
.
num_headers
==
1
);
ASSERT
(
strcmp
(
ri
.
http_headers
[
0
].
name
,
"Bah
\r\n
"
)
==
0
);
// TODO(lsm): Fix this. Header value may span multiple lines.
ASSERT
(
parse_http_request
(
req4
,
&
ri
)
==
1
);
ASSERT
(
ri
.
num_headers
==
3
);
ASSERT
(
strcmp
(
ri
.
http_headers
[
0
].
name
,
"A"
)
==
0
);
ASSERT
(
strcmp
(
ri
.
http_headers
[
0
].
value
,
"foo bar"
)
==
0
);
ASSERT
(
strcmp
(
ri
.
http_headers
[
1
].
name
,
"B"
)
==
0
);
ASSERT
(
strcmp
(
ri
.
http_headers
[
1
].
value
,
"bar"
)
==
0
);
ASSERT
(
strcmp
(
ri
.
http_headers
[
2
].
name
,
"baz
\r\n\r\n
"
)
==
0
);
ASSERT
(
strcmp
(
ri
.
http_headers
[
2
].
value
,
""
)
==
0
);
// TODO(lsm): add more tests.
}
...
...
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