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
a69bc2cb
Commit
a69bc2cb
authored
Dec 18, 2015
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
https: robustify HTTP/2 connection test
parent
c7a2b2bd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
65 additions
and
2 deletions
+65
-2
modules/access/http/h2conn_test.c
modules/access/http/h2conn_test.c
+65
-2
No files found.
modules/access/http/h2conn_test.c
View file @
a69bc2cb
...
...
@@ -55,9 +55,44 @@ static void conn_send(struct vlc_h2_frame *f)
free
(
f
);
}
enum
{
DATA
,
HEADERS
,
PRIORITY
,
RST_STREAM
,
SETTINGS
,
PUSH_PROMISE
,
PING
,
GOAWAY
,
WINDOW_UPDATE
,
CONTINUATION
,
};
static
void
conn_expect
(
uint_fast8_t
wanted
)
{
size_t
len
;
ssize_t
val
;
uint8_t
hdr
[
9
];
uint8_t
got
;
do
{
val
=
recv
(
external_fd
,
hdr
,
9
,
MSG_WAITALL
);
assert
(
val
==
9
);
assert
(
hdr
[
0
]
==
0
);
/* Check type. We do not currently validate WINDOW_UPDATE. */
got
=
hdr
[
3
];
assert
(
wanted
==
got
||
WINDOW_UPDATE
==
got
);
len
=
(
hdr
[
1
]
<<
8
)
|
hdr
[
2
];
if
(
len
>
0
)
{
char
buf
[
len
];
val
=
recv
(
external_fd
,
buf
,
len
,
MSG_WAITALL
);
assert
(
val
==
(
ssize_t
)
len
);
}
}
while
(
got
!=
wanted
);
}
static
void
conn_create
(
void
)
{
ssize_t
val
;
int
fds
[
2
];
char
hello
[
24
];
if
(
socketpair
(
PF_LOCAL
,
SOCK_STREAM
|
SOCK_CLOEXEC
,
0
,
fds
))
assert
(
!
"socketpair"
);
...
...
@@ -70,6 +105,12 @@ static void conn_create(void)
conn
=
vlc_h2_conn_create
(
tls
);
assert
(
conn
!=
NULL
);
conn_send
(
vlc_h2_frame_settings
());
val
=
recv
(
external_fd
,
hello
,
24
,
MSG_WAITALL
);
assert
(
val
==
24
);
assert
(
!
memcmp
(
hello
,
"PRI * HTTP/2.0
\r\n
"
,
16
));
conn_expect
(
SETTINGS
);
conn_expect
(
SETTINGS
);
}
static
void
conn_destroy
(
void
)
...
...
@@ -128,17 +169,20 @@ int main(void)
conn_create
();
conn_send
(
vlc_h2_frame_ping
(
42
));
conn_expect
(
PING
);
/* Test rejected stream */
sid
+=
2
;
s
=
stream_open
();
assert
(
s
!=
NULL
);
conn_expect
(
HEADERS
);
conn_send
(
vlc_h2_frame_rst_stream
(
sid
,
VLC_H2_REFUSED_STREAM
));
m
=
vlc_http_stream_read_headers
(
s
);
assert
(
m
==
NULL
);
b
=
vlc_http_stream_read
(
s
);
assert
(
b
==
NULL
);
vlc_http_stream_close
(
s
,
false
);
conn_expect
(
RST_STREAM
);
/* Test accepted stream */
sid
+=
2
;
...
...
@@ -149,10 +193,14 @@ int main(void)
assert
(
m
!=
NULL
);
vlc_http_msg_destroy
(
m
);
/* Test late data */
stream_data
(
3
,
"Hello "
,
false
);
stream_data
(
3
,
"Hello "
,
false
);
/* late data */
stream_data
(
3
,
"world!"
,
true
);
conn_expect
(
HEADERS
);
conn_expect
(
RST_STREAM
);
conn_expect
(
RST_STREAM
);
conn_expect
(
RST_STREAM
);
/* Test continuation then accepted stream */
sid
+=
2
;
s
=
stream_open
();
...
...
@@ -177,6 +225,10 @@ int main(void)
assert
(
b
==
NULL
);
vlc_http_msg_destroy
(
m
);
conn_expect
(
HEADERS
);
conn_expect
(
RST_STREAM
);
conn_expect
(
RST_STREAM
);
/* Test accepted stream after continuation */
sid
+=
2
;
s
=
stream_open
();
...
...
@@ -197,6 +249,11 @@ int main(void)
assert
(
b
==
NULL
);
vlc_http_msg_destroy
(
m
);
conn_expect
(
HEADERS
);
conn_expect
(
HEADERS
);
conn_expect
(
RST_STREAM
);
conn_expect
(
RST_STREAM
);
/* Test multiple streams in non-LIFO order */
sid
+=
2
;
s
=
stream_open
();
...
...
@@ -214,6 +271,12 @@ int main(void)
assert
(
m
!=
NULL
);
vlc_http_msg_destroy
(
m
);
conn_expect
(
HEADERS
);
conn_expect
(
HEADERS
);
conn_expect
(
RST_STREAM
);
conn_expect
(
RST_STREAM
);
/* might or might not seen one or two extra RST_STREAM now */
/* Test graceful connection termination */
sid
+=
2
;
s
=
stream_open
();
...
...
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