Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
547418a7
Commit
547418a7
authored
Dec 18, 2015
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
https: improve file test coverage
parent
a69bc2cb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
4 deletions
+41
-4
modules/access/http/file_test.c
modules/access/http/file_test.c
+41
-4
No files found.
modules/access/http/file_test.c
View file @
547418a7
/*****************************************************************************
*
message_test.c: HTTP request/response
*
file_test.c: HTTP file download test
*****************************************************************************
* Copyright (C) 2015 Rémi Denis-Courmont
*
...
...
@@ -38,6 +38,7 @@ static const char ua[] = PACKAGE_NAME "/" PACKAGE_VERSION " (test suite)";
static
const
char
*
replies
[
2
]
=
{
NULL
,
NULL
};
static
uintmax_t
offset
=
0
;
static
bool
etags
=
false
;
int
main
(
void
)
{
...
...
@@ -63,6 +64,7 @@ int main(void)
"
\r\n
"
;
offset
=
0
;
etags
=
true
;
f
=
vlc_http_file_create
(
NULL
,
url
,
ua
,
NULL
);
assert
(
f
!=
NULL
);
assert
(
vlc_http_file_get_status
(
f
)
==
200
);
...
...
@@ -82,6 +84,7 @@ int main(void)
replies
[
0
]
=
"HTTP/1.1 206 Partial Content
\r\n
"
"Content-Range: bytes 0-2344/2345
\r\n
"
"ETag: W/
\"
foobar42
\"\r\n
"
"Last-Modified: Mon, 21 Oct 2013 20:13:22 GMT
\r\n
"
"
\r\n
"
;
offset
=
0
;
...
...
@@ -89,20 +92,24 @@ int main(void)
assert
(
f
!=
NULL
);
assert
(
vlc_http_file_can_seek
(
f
));
assert
(
vlc_http_file_get_size
(
f
)
==
2345
);
assert
(
vlc_http_file_read
(
f
)
==
NULL
);
/* Seek success */
replies
[
0
]
=
"HTTP/1.1 206 Partial Content
\r\n
"
"Content-Range: bytes 1234-3455/3456
\r\n
"
"ETag: W/
\"
foobar42
\"\r\n
"
"Last-Modified: Mon, 21 Oct 2013 20:13:22 GMT
\r\n
"
"
\r\n
"
;
assert
(
vlc_http_file_seek
(
f
,
offset
=
1234
)
==
0
);
assert
(
vlc_http_file_can_seek
(
f
));
assert
(
vlc_http_file_get_size
(
f
)
==
3456
);
assert
(
vlc_http_file_read
(
f
)
==
NULL
);
/* Seek too far */
replies
[
0
]
=
"HTTP/1.1 416 Range Not Satisfiable
\r\n
"
"Content-Range: bytes */4567
\r\n
"
"ETag: W/
\"
foobar42
\"\r\n
"
"Last-Modified: Mon, 21 Oct 2013 20:13:22 GMT
\r\n
"
"
\r\n
"
;
vlc_http_file_seek
(
f
,
offset
=
5678
);
assert
(
vlc_http_file_can_seek
(
f
));
...
...
@@ -139,6 +146,25 @@ int main(void)
assert
(
vlc_http_file_get_redirect
(
f
)
==
NULL
);
vlc_http_file_destroy
(
f
);
/* No entity tags */
replies
[
0
]
=
"HTTP/1.1 206 Partial Content
\r\n
"
"Content-Range: bytes 0-2344/2345
\r\n
"
"Last-Modified: Mon, 21 Oct 2013 20:13:22 GMT
\r\n
"
"
\r\n
"
;
offset
=
0
;
etags
=
false
;
f
=
vlc_http_file_create
(
NULL
,
url
,
ua
,
NULL
);
assert
(
f
!=
NULL
);
assert
(
vlc_http_file_can_seek
(
f
));
replies
[
0
]
=
"HTTP/1.1 206 Partial Content
\r\n
"
"Content-Range: bytes 1234-3455/3456
\r\n
"
"Last-Modified: Mon, 21 Oct 2013 20:13:22 GMT
\r\n
"
"
\r\n
"
;
assert
(
vlc_http_file_seek
(
f
,
offset
=
1234
)
==
0
);
vlc_http_file_destroy
(
f
);
/* Dummy API calls */
f
=
vlc_http_file_create
(
NULL
,
"ftp://localhost/foo"
,
NULL
,
NULL
);
...
...
@@ -238,11 +264,22 @@ struct vlc_http_msg *vlc_https_request(struct vlc_http_mgr *mgr,
assert
(
str
!=
NULL
&&
!
strncmp
(
str
,
"bytes="
,
6
)
&&
strtoul
(
str
+
6
,
&
end
,
10
)
==
offset
&&
*
end
==
'-'
);
time_t
mtime
=
vlc_http_msg_get_time
(
req
,
"If-Unmodified-Since"
);
str
=
vlc_http_msg_get_header
(
req
,
"If-Match"
);
if
(
offset
!=
0
)
assert
(
str
!=
NULL
&&
!
strcmp
(
str
,
"
\"
foobar42
\"
"
));
if
(
etags
)
{
if
(
offset
!=
0
)
assert
(
str
!=
NULL
&&
!
strcmp
(
str
,
"
\"
foobar42
\"
"
));
else
if
(
str
!=
NULL
)
assert
(
strcmp
(
str
,
"*"
)
||
strcmp
(
str
,
"
\"
foobar42
\"
"
));
}
else
assert
(
str
==
NULL
||
strcmp
(
str
,
"*"
)
||
strcmp
(
str
,
"
\"
foobar42
\"
"
));
{
if
(
offset
!=
0
)
assert
(
mtime
==
1382386402
);
}
return
vlc_http_stream_read_headers
(
&
stream
);
}
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