Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nghttp2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
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
Libraries
nghttp2
Commits
e14da859
Commit
e14da859
authored
Jan 11, 2016
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into simple-extensions
parents
0248d979
863addcd
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
571 additions
and
369 deletions
+571
-369
doc/h2load.1
doc/h2load.1
+7
-6
doc/h2load.1.rst
doc/h2load.1.rst
+5
-4
doc/nghttp.1
doc/nghttp.1
+2
-2
doc/nghttpd.1
doc/nghttpd.1
+7
-2
doc/nghttpd.1.rst
doc/nghttpd.1.rst
+4
-0
doc/nghttpx.1
doc/nghttpx.1
+7
-6
doc/nghttpx.1.rst
doc/nghttpx.1.rst
+5
-4
lib/includes/nghttp2/nghttp2.h
lib/includes/nghttp2/nghttp2.h
+6
-0
lib/nghttp2_session.c
lib/nghttp2_session.c
+49
-27
lib/nghttp2_session.h
lib/nghttp2_session.h
+4
-0
lib/nghttp2_submit.c
lib/nghttp2_submit.c
+71
-18
tests/nghttp2_session_test.c
tests/nghttp2_session_test.c
+243
-300
tests/nghttp2_test_helper.c
tests/nghttp2_test_helper.c
+116
-0
tests/nghttp2_test_helper.h
tests/nghttp2_test_helper.h
+45
-0
No files found.
doc/h2load.1
View file @
e14da859
.\" Man page generated from reStructuredText.
.\" Man page generated from reStructuredText.
.
.
.TH "H2LOAD" "1" "
December 23, 2015" "1.6.0
" "nghttp2"
.TH "H2LOAD" "1" "
January 11, 2016" "1.6.1-DEV
" "nghttp2"
.SH NAME
.SH NAME
h2load \- HTTP/2 benchmarking tool
h2load \- HTTP/2 benchmarking tool
.
.
...
@@ -88,11 +88,12 @@ scheme, host or port values.
...
@@ -88,11 +88,12 @@ scheme, host or port values.
.UNINDENT
.UNINDENT
.INDENT 0.0
.INDENT 0.0
.TP
.TP
.B \-m, \-\-max\-concurrent\-streams=(auto|<N>)
.B \-m, \-\-max\-concurrent\-streams=<N>
Max concurrent streams to issue per session. If "auto"
Max concurrent streams to issue per session. When
is given, the number of given URIs is used.
http/1.1 is used, this specifies the number of HTTP
pipelining requests in\-flight.
.sp
.sp
Default: \fB
auto
\fP
Default: \fB
1
\fP
.UNINDENT
.UNINDENT
.INDENT 0.0
.INDENT 0.0
.TP
.TP
...
@@ -410,6 +411,6 @@ window size described in HTTP/2 and SPDY protocol specification.
...
@@ -410,6 +411,6 @@ window size described in HTTP/2 and SPDY protocol specification.
.SH AUTHOR
.SH AUTHOR
Tatsuhiro Tsujikawa
Tatsuhiro Tsujikawa
.SH COPYRIGHT
.SH COPYRIGHT
2012, 2015, Tatsuhiro Tsujikawa
2012, 2015,
2016,
Tatsuhiro Tsujikawa
.\" Generated by docutils manpage writer.
.\" Generated by docutils manpage writer.
.
.
doc/h2load.1.rst
View file @
e14da859
...
@@ -63,12 +63,13 @@ OPTIONS
...
@@ -63,12 +63,13 @@ OPTIONS
are used solely. Definition of a base URI overrides all
are used solely. Definition of a base URI overrides all
scheme, host or port values.
scheme, host or port values.
.. option:: -m, --max-concurrent-streams=
(auto|<N>)
.. option:: -m, --max-concurrent-streams=
<N>
Max concurrent streams to issue per session. If "auto"
Max concurrent streams to issue per session. When
is given, the number of given URIs is used.
http/1.1 is used, this specifies the number of HTTP
pipelining requests in-flight.
Default: ``
auto
``
Default: ``
1
``
.. option:: -w, --window-bits=<N>
.. option:: -w, --window-bits=<N>
...
...
doc/nghttp.1
View file @
e14da859
.\" Man page generated from reStructuredText.
.\" Man page generated from reStructuredText.
.
.
.TH "NGHTTP" "1" "
December 23, 2015" "1.6.0
" "nghttp2"
.TH "NGHTTP" "1" "
January 11, 2016" "1.6.1-DEV
" "nghttp2"
.SH NAME
.SH NAME
nghttp \- HTTP/2 client
nghttp \- HTTP/2 client
.
.
...
@@ -296,6 +296,6 @@ on stream 11 with the weight 2.
...
@@ -296,6 +296,6 @@ on stream 11 with the weight 2.
.SH AUTHOR
.SH AUTHOR
Tatsuhiro Tsujikawa
Tatsuhiro Tsujikawa
.SH COPYRIGHT
.SH COPYRIGHT
2012, 2015, Tatsuhiro Tsujikawa
2012, 2015,
2016,
Tatsuhiro Tsujikawa
.\" Generated by docutils manpage writer.
.\" Generated by docutils manpage writer.
.
.
doc/nghttpd.1
View file @
e14da859
.\" Man page generated from reStructuredText.
.\" Man page generated from reStructuredText.
.
.
.TH "NGHTTPD" "1" "
December 23, 2015" "1.6.0
" "nghttp2"
.TH "NGHTTPD" "1" "
January 11, 2016" "1.6.1-DEV
" "nghttp2"
.SH NAME
.SH NAME
nghttpd \- HTTP/2 server
nghttpd \- HTTP/2 server
.
.
...
@@ -180,6 +180,11 @@ Default: \fB/etc/mime.types\fP
...
@@ -180,6 +180,11 @@ Default: \fB/etc/mime.types\fP
.UNINDENT
.UNINDENT
.INDENT 0.0
.INDENT 0.0
.TP
.TP
.B \-\-no\-content\-length
Don\(aqt send content\-length header field.
.UNINDENT
.INDENT 0.0
.TP
.B \-\-version
.B \-\-version
Display version information and exit.
Display version information and exit.
.UNINDENT
.UNINDENT
...
@@ -197,6 +202,6 @@ The <SIZE> argument is an integer and an optional unit (e.g., 10K is
...
@@ -197,6 +202,6 @@ The <SIZE> argument is an integer and an optional unit (e.g., 10K is
.SH AUTHOR
.SH AUTHOR
Tatsuhiro Tsujikawa
Tatsuhiro Tsujikawa
.SH COPYRIGHT
.SH COPYRIGHT
2012, 2015, Tatsuhiro Tsujikawa
2012, 2015,
2016,
Tatsuhiro Tsujikawa
.\" Generated by docutils manpage writer.
.\" Generated by docutils manpage writer.
.
.
doc/nghttpd.1.rst
View file @
e14da859
...
@@ -139,6 +139,10 @@ OPTIONS
...
@@ -139,6 +139,10 @@ OPTIONS
Default: ``/etc/mime.types``
Default: ``/etc/mime.types``
.. option:: --no-content-length
Don't send content-length header field.
.. option:: --version
.. option:: --version
Display version information and exit.
Display version information and exit.
...
...
doc/nghttpx.1
View file @
e14da859
.\
" Man page generated from reStructuredText.
.\
" Man page generated from reStructuredText.
.
.
.TH "
NGHTTPX
" "
1
" "
December
23
,
2015
" "
1.6.0
" "
nghttp2
"
.TH "
NGHTTPX
" "
1
" "
January
11
,
2016
" "
1.6.1
-
DEV
" "
nghttp2
"
.SH NAME
.SH NAME
nghttpx \- HTTP/2 proxy
nghttpx \- HTTP/2 proxy
.
.
...
@@ -896,8 +896,8 @@ Example: \fI\%\-\-add\-response\-header\fP="foo: bar"
...
@@ -896,8 +896,8 @@ Example: \fI\%\-\-add\-response\-header\fP="foo: bar"
.INDENT 0.0
.INDENT 0.0
.TP
.TP
.B \-\-header\-field\-buffer=<SIZE>
.B \-\-header\-field\-buffer=<SIZE>
Set maximum
buffer size for incoming HTTP header field
Set maximum
buffer size for incoming HTTP request header
list. This is the sum of header name and value
in
field list. This is the sum of header name and value
in
bytes.
bytes.
.sp
.sp
Default:
\f
B64K
\f
P
Default:
\f
B64K
\f
P
...
@@ -905,8 +905,9 @@ Default: \fB64K\fP
...
@@ -905,8 +905,9 @@ Default: \fB64K\fP
.INDENT 0.0
.INDENT 0.0
.TP
.TP
.B \-\-max\-header\-fields=<N>
.B \-\-max\-header\-fields=<N>
Set maximum number of incoming HTTP header fields, which
Set maximum number of incoming HTTP request header
appear in one request or response header field list.
fields, which appear in one request or response header
field list.
.sp
.sp
Default:
\f
B100
\f
P
Default:
\f
B100
\f
P
.UNINDENT
.UNINDENT
...
@@ -1458,6 +1459,6 @@ App.new
...
@@ -1458,6 +1459,6 @@ App.new
.SH AUTHOR
.SH AUTHOR
Tatsuhiro Tsujikawa
Tatsuhiro Tsujikawa
.SH COPYRIGHT
.SH COPYRIGHT
2012, 2015, Tatsuhiro Tsujikawa
2012, 2015,
2016,
Tatsuhiro Tsujikawa
.
\"
Generated by docutils manpage writer.
.
\"
Generated by docutils manpage writer.
.
.
doc/nghttpx.1.rst
View file @
e14da859
...
@@ -797,16 +797,17 @@ HTTP
...
@@ -797,16 +797,17 @@ HTTP
.. option:: --header-field-buffer=<SIZE>
.. option:: --header-field-buffer=<SIZE>
Set maximum
buffer size for incoming HTTP header field
Set maximum
buffer size for incoming HTTP request header
list. This is the sum of header name and value
in
field list. This is the sum of header name and value
in
bytes.
bytes.
Default: ``64K``
Default: ``64K``
.. option:: --max-header-fields=<N>
.. option:: --max-header-fields=<N>
Set maximum number of incoming HTTP header fields, which
Set maximum number of incoming HTTP request header
appear in one request or response header field list.
fields, which appear in one request or response header
field list.
Default: ``100``
Default: ``100``
...
...
lib/includes/nghttp2/nghttp2.h
View file @
e14da859
...
@@ -3299,6 +3299,8 @@ nghttp2_priority_spec_check_default(const nghttp2_priority_spec *pri_spec);
...
@@ -3299,6 +3299,8 @@ nghttp2_priority_spec_check_default(const nghttp2_priority_spec *pri_spec);
* :enum:`NGHTTP2_ERR_INVALID_ARGUMENT`
* :enum:`NGHTTP2_ERR_INVALID_ARGUMENT`
* Trying to depend on itself (new stream ID equals
* Trying to depend on itself (new stream ID equals
* ``pri_spec->stream_id``).
* ``pri_spec->stream_id``).
* :enum:`NGHTTP2_ERR_PROTO`
* The |session| is server session.
*
*
* .. warning::
* .. warning::
*
*
...
@@ -3371,6 +3373,8 @@ nghttp2_submit_request(nghttp2_session *session,
...
@@ -3371,6 +3373,8 @@ nghttp2_submit_request(nghttp2_session *session,
* processed yet. Normally, this does not happen, but when
* processed yet. Normally, this does not happen, but when
* application wrongly calls `nghttp2_submit_response()` twice,
* application wrongly calls `nghttp2_submit_response()` twice,
* this may happen.
* this may happen.
* :enum:`NGHTTP2_ERR_PROTO`
* The |session| is client session.
*
*
* .. warning::
* .. warning::
*
*
...
@@ -3515,6 +3519,8 @@ NGHTTP2_EXTERN int nghttp2_submit_trailer(nghttp2_session *session,
...
@@ -3515,6 +3519,8 @@ NGHTTP2_EXTERN int nghttp2_submit_trailer(nghttp2_session *session,
* DATA or HEADERS has been already submitted and not fully
* DATA or HEADERS has been already submitted and not fully
* processed yet. This happens if stream denoted by |stream_id|
* processed yet. This happens if stream denoted by |stream_id|
* is in reserved state.
* is in reserved state.
* :enum:`NGHTTP2_ERR_PROTO`
* The |stream_id| is -1, and |session| is server session.
*
*
* .. warning::
* .. warning::
*
*
...
...
lib/nghttp2_session.c
View file @
e14da859
...
@@ -130,7 +130,7 @@ static int session_detect_idle_stream(nghttp2_session *session,
...
@@ -130,7 +130,7 @@ static int session_detect_idle_stream(nghttp2_session *session,
int32_t
stream_id
)
{
int32_t
stream_id
)
{
/* Assume that stream object with stream_id does not exist */
/* Assume that stream object with stream_id does not exist */
if
(
nghttp2_session_is_my_stream_id
(
session
,
stream_id
))
{
if
(
nghttp2_session_is_my_stream_id
(
session
,
stream_id
))
{
if
(
session
->
next_stream_id
<=
(
uint32_t
)
stream_id
)
{
if
(
session
->
sent_stream_id
<
stream_id
)
{
return
1
;
return
1
;
}
}
return
0
;
return
0
;
...
@@ -1379,7 +1379,9 @@ static int session_predicate_request_headers_send(nghttp2_session *session,
...
@@ -1379,7 +1379,9 @@ static int session_predicate_request_headers_send(nghttp2_session *session,
* NGHTTP2_ERR_INVALID_STREAM_STATE
* NGHTTP2_ERR_INVALID_STREAM_STATE
* The state of the stream is not valid.
* The state of the stream is not valid.
* NGHTTP2_ERR_SESSION_CLOSING
* NGHTTP2_ERR_SESSION_CLOSING
* This session is closing.
* This session is closing.
* NGHTTP2_ERR_PROTO
* Client side attempted to send response.
*/
*/
static
int
session_predicate_response_headers_send
(
nghttp2_session
*
session
,
static
int
session_predicate_response_headers_send
(
nghttp2_session
*
session
,
nghttp2_stream
*
stream
)
{
nghttp2_stream
*
stream
)
{
...
@@ -1389,6 +1391,9 @@ static int session_predicate_response_headers_send(nghttp2_session *session,
...
@@ -1389,6 +1391,9 @@ static int session_predicate_response_headers_send(nghttp2_session *session,
return
rv
;
return
rv
;
}
}
assert
(
stream
);
assert
(
stream
);
if
(
!
session
->
server
)
{
return
NGHTTP2_ERR_PROTO
;
}
if
(
nghttp2_session_is_my_stream_id
(
session
,
stream
->
stream_id
))
{
if
(
nghttp2_session_is_my_stream_id
(
session
,
stream
->
stream_id
))
{
return
NGHTTP2_ERR_INVALID_STREAM_ID
;
return
NGHTTP2_ERR_INVALID_STREAM_ID
;
}
}
...
@@ -1422,6 +1427,8 @@ static int session_predicate_response_headers_send(nghttp2_session *session,
...
@@ -1422,6 +1427,8 @@ static int session_predicate_response_headers_send(nghttp2_session *session,
* NGHTTP2_ERR_START_STREAM_NOT_ALLOWED
* NGHTTP2_ERR_START_STREAM_NOT_ALLOWED
* New stream cannot be created because GOAWAY is already sent or
* New stream cannot be created because GOAWAY is already sent or
* received.
* received.
* NGHTTP2_ERR_PROTO
* Client side attempted to send push response.
*/
*/
static
int
static
int
session_predicate_push_response_headers_send
(
nghttp2_session
*
session
,
session_predicate_push_response_headers_send
(
nghttp2_session
*
session
,
...
@@ -1433,6 +1440,9 @@ session_predicate_push_response_headers_send(nghttp2_session *session,
...
@@ -1433,6 +1440,9 @@ session_predicate_push_response_headers_send(nghttp2_session *session,
return
rv
;
return
rv
;
}
}
assert
(
stream
);
assert
(
stream
);
if
(
!
session
->
server
)
{
return
NGHTTP2_ERR_PROTO
;
}
if
(
stream
->
state
!=
NGHTTP2_STREAM_RESERVED
)
{
if
(
stream
->
state
!=
NGHTTP2_STREAM_RESERVED
)
{
return
NGHTTP2_ERR_PROTO
;
return
NGHTTP2_ERR_PROTO
;
}
}
...
@@ -1901,6 +1911,11 @@ static int session_prep_frame(nghttp2_session *session,
...
@@ -1901,6 +1911,11 @@ static int session_prep_frame(nghttp2_session *session,
DEBUGF
(
fprintf
(
stderr
,
"send: HEADERS finally serialized in %zd bytes
\n
"
,
DEBUGF
(
fprintf
(
stderr
,
"send: HEADERS finally serialized in %zd bytes
\n
"
,
nghttp2_bufs_len
(
&
session
->
aob
.
framebufs
)));
nghttp2_bufs_len
(
&
session
->
aob
.
framebufs
)));
if
(
frame
->
headers
.
cat
==
NGHTTP2_HCAT_REQUEST
)
{
assert
(
session
->
sent_stream_id
<
frame
->
hd
.
stream_id
);
session
->
sent_stream_id
=
frame
->
hd
.
stream_id
;
}
break
;
break
;
}
}
case
NGHTTP2_PRIORITY
:
{
case
NGHTTP2_PRIORITY
:
{
...
@@ -1970,6 +1985,10 @@ static int session_prep_frame(nghttp2_session *session,
...
@@ -1970,6 +1985,10 @@ static int session_prep_frame(nghttp2_session *session,
return
rv
;
return
rv
;
}
}
assert
(
session
->
sent_stream_id
+
2
<=
frame
->
push_promise
.
promised_stream_id
);
session
->
sent_stream_id
=
frame
->
push_promise
.
promised_stream_id
;
break
;
break
;
}
}
case
NGHTTP2_PING
:
case
NGHTTP2_PING
:
...
@@ -3805,13 +3824,14 @@ int nghttp2_session_on_rst_stream_received(nghttp2_session *session,
...
@@ -3805,13 +3824,14 @@ int nghttp2_session_on_rst_stream_received(nghttp2_session *session,
return
session_handle_invalid_connection
(
session
,
frame
,
NGHTTP2_ERR_PROTO
,
return
session_handle_invalid_connection
(
session
,
frame
,
NGHTTP2_ERR_PROTO
,
"RST_STREAM: stream_id == 0"
);
"RST_STREAM: stream_id == 0"
);
}
}
if
(
session_detect_idle_stream
(
session
,
frame
->
hd
.
stream_id
))
{
return
session_handle_invalid_connection
(
session
,
frame
,
NGHTTP2_ERR_PROTO
,
"RST_STREAM: stream in idle"
);
}
stream
=
nghttp2_session_get_stream
(
session
,
frame
->
hd
.
stream_id
);
stream
=
nghttp2_session_get_stream
(
session
,
frame
->
hd
.
stream_id
);
if
(
!
stream
)
{
if
(
stream
)
{
if
(
session_detect_idle_stream
(
session
,
frame
->
hd
.
stream_id
))
{
return
session_handle_invalid_connection
(
session
,
frame
,
NGHTTP2_ERR_PROTO
,
"RST_STREAM: stream in idle"
);
}
}
else
{
/* We may use stream->shut_flags for strict error checking. */
/* We may use stream->shut_flags for strict error checking. */
nghttp2_stream_shutdown
(
stream
,
NGHTTP2_SHUT_RD
);
nghttp2_stream_shutdown
(
stream
,
NGHTTP2_SHUT_RD
);
}
}
...
@@ -4249,21 +4269,20 @@ int nghttp2_session_on_push_promise_received(nghttp2_session *session,
...
@@ -4249,21 +4269,20 @@ int nghttp2_session_on_push_promise_received(nghttp2_session *session,
session
,
frame
,
NGHTTP2_ERR_PROTO
,
session
,
frame
,
NGHTTP2_ERR_PROTO
,
"PUSH_PROMISE: invalid promised_stream_id"
);
"PUSH_PROMISE: invalid promised_stream_id"
);
}
}
if
(
session_detect_idle_stream
(
session
,
frame
->
hd
.
stream_id
))
{
return
session_inflate_handle_invalid_connection
(
session
,
frame
,
NGHTTP2_ERR_PROTO
,
"PUSH_PROMISE: stream in idle"
);
}
session
->
last_recv_stream_id
=
frame
->
push_promise
.
promised_stream_id
;
session
->
last_recv_stream_id
=
frame
->
push_promise
.
promised_stream_id
;
stream
=
nghttp2_session_get_stream
(
session
,
frame
->
hd
.
stream_id
);
stream
=
nghttp2_session_get_stream
(
session
,
frame
->
hd
.
stream_id
);
if
(
!
stream
||
stream
->
state
==
NGHTTP2_STREAM_CLOSING
||
if
(
!
stream
||
stream
->
state
==
NGHTTP2_STREAM_CLOSING
||
!
session
->
pending_enable_push
||
!
session
->
pending_enable_push
||
session
->
num_incoming_reserved_streams
>=
session
->
num_incoming_reserved_streams
>=
session
->
max_incoming_reserved_streams
)
{
session
->
max_incoming_reserved_streams
)
{
if
(
!
stream
)
{
/* Currently, client does not retain closed stream, so we don't
if
(
session_detect_idle_stream
(
session
,
frame
->
hd
.
stream_id
))
{
check NGHTTP2_SHUT_RD condition here. */
return
session_inflate_handle_invalid_connection
(
session
,
frame
,
NGHTTP2_ERR_PROTO
,
"PUSH_PROMISE: stream in idle"
);
}
/* Currently, client does not retain closed stream, so we don't
check NGHTTP2_SHUT_RD condition here. */
}
rv
=
nghttp2_session_add_rst_stream
(
rv
=
nghttp2_session_add_rst_stream
(
session
,
frame
->
push_promise
.
promised_stream_id
,
NGHTTP2_CANCEL
);
session
,
frame
->
push_promise
.
promised_stream_id
,
NGHTTP2_CANCEL
);
...
@@ -4415,12 +4434,14 @@ static int session_on_stream_window_update_received(nghttp2_session *session,
...
@@ -4415,12 +4434,14 @@ static int session_on_stream_window_update_received(nghttp2_session *session,
nghttp2_frame
*
frame
)
{
nghttp2_frame
*
frame
)
{
int
rv
;
int
rv
;
nghttp2_stream
*
stream
;
nghttp2_stream
*
stream
;
if
(
session_detect_idle_stream
(
session
,
frame
->
hd
.
stream_id
))
{
return
session_handle_invalid_connection
(
session
,
frame
,
NGHTTP2_ERR_PROTO
,
"WINDOW_UPDATE to idle stream"
);
}
stream
=
nghttp2_session_get_stream
(
session
,
frame
->
hd
.
stream_id
);
stream
=
nghttp2_session_get_stream
(
session
,
frame
->
hd
.
stream_id
);
if
(
!
stream
)
{
if
(
!
stream
)
{
if
(
session_detect_idle_stream
(
session
,
frame
->
hd
.
stream_id
))
{
return
session_handle_invalid_connection
(
session
,
frame
,
NGHTTP2_ERR_PROTO
,
"WINDOW_UPDATE to idle stream"
);
}
return
0
;
return
0
;
}
}
if
(
state_reserved_remote
(
session
,
stream
))
{
if
(
state_reserved_remote
(
session
,
stream
))
{
...
@@ -4736,14 +4757,15 @@ static int session_on_data_received_fail_fast(nghttp2_session *session) {
...
@@ -4736,14 +4757,15 @@ static int session_on_data_received_fail_fast(nghttp2_session *session) {
failure_reason
=
"DATA: stream_id == 0"
;
failure_reason
=
"DATA: stream_id == 0"
;
goto
fail
;
goto
fail
;
}
}
if
(
session_detect_idle_stream
(
session
,
stream_id
))
{
failure_reason
=
"DATA: stream in idle"
;
error_code
=
NGHTTP2_PROTOCOL_ERROR
;
goto
fail
;
}
stream
=
nghttp2_session_get_stream
(
session
,
stream_id
);
stream
=
nghttp2_session_get_stream
(
session
,
stream_id
);
if
(
!
stream
)
{
if
(
!
stream
)
{
if
(
session_detect_idle_stream
(
session
,
stream_id
))
{
failure_reason
=
"DATA: stream in idle"
;
error_code
=
NGHTTP2_PROTOCOL_ERROR
;
goto
fail
;
}
stream
=
nghttp2_session_get_stream_raw
(
session
,
stream_id
);
stream
=
nghttp2_session_get_stream_raw
(
session
,
stream_id
);
if
(
stream
&&
(
stream
->
shut_flags
&
NGHTTP2_SHUT_RD
))
{
if
(
stream
&&
(
stream
->
shut_flags
&
NGHTTP2_SHUT_RD
))
{
failure_reason
=
"DATA: stream closed"
;
failure_reason
=
"DATA: stream closed"
;
...
...
lib/nghttp2_session.h
View file @
e14da859
...
@@ -247,6 +247,10 @@ struct nghttp2_session {
...
@@ -247,6 +247,10 @@ struct nghttp2_session {
size_t
obq_flood_counter_
;
size_t
obq_flood_counter_
;
/* Next Stream ID. Made unsigned int to detect >= (1 << 31). */
/* Next Stream ID. Made unsigned int to detect >= (1 << 31). */
uint32_t
next_stream_id
;
uint32_t
next_stream_id
;
/* The last stream ID this session initiated. For client session,
this is the last stream ID it has sent. For server session, it
is the last promised stream ID sent in PUSH_PROMISE. */
int32_t
sent_stream_id
;
/* The largest stream ID received so far */
/* The largest stream ID received so far */
int32_t
last_recv_stream_id
;
int32_t
last_recv_stream_id
;
/* The largest stream ID which has been processed in some way. This
/* The largest stream ID which has been processed in some way. This
...
...
lib/nghttp2_submit.c
View file @
e14da859
...
@@ -32,6 +32,35 @@
...
@@ -32,6 +32,35 @@
#include "nghttp2_helper.h"
#include "nghttp2_helper.h"
#include "nghttp2_priority_spec.h"
#include "nghttp2_priority_spec.h"
/*
* Detects the dependency error, that is stream attempted to depend on
* itself. If |stream_id| is -1, we use session->next_stream_id as
* stream ID.
*
* This function returns 0 if it succeeds, or one of the following
* error codes:
*
* NGHTTP2_ERR_INVALID_ARGUMENT
* Stream attempted to depend on itself.
*/
static
int
detect_self_dependency
(
nghttp2_session
*
session
,
int32_t
stream_id
,
const
nghttp2_priority_spec
*
pri_spec
)
{
assert
(
pri_spec
);
if
(
stream_id
==
-
1
)
{
if
((
int32_t
)
session
->
next_stream_id
==
pri_spec
->
stream_id
)
{
return
NGHTTP2_ERR_INVALID_ARGUMENT
;
}
return
0
;
}
if
(
stream_id
==
pri_spec
->
stream_id
)
{
return
NGHTTP2_ERR_INVALID_ARGUMENT
;
}
return
0
;
}
/* This function takes ownership of |nva_copy|. Regardless of the
/* This function takes ownership of |nva_copy|. Regardless of the
return value, the caller must not free |nva_copy| after this
return value, the caller must not free |nva_copy| after this
function returns. */
function returns. */
...
@@ -50,21 +79,6 @@ static int32_t submit_headers_shared(nghttp2_session *session, uint8_t flags,
...
@@ -50,21 +79,6 @@ static int32_t submit_headers_shared(nghttp2_session *session, uint8_t flags,
mem
=
&
session
->
mem
;
mem
=
&
session
->
mem
;
if
(
stream_id
==
0
)
{
rv
=
NGHTTP2_ERR_INVALID_ARGUMENT
;
goto
fail
;
}
if
(
stream_id
==
-
1
)
{
if
((
int32_t
)
session
->
next_stream_id
==
pri_spec
->
stream_id
)
{
rv
=
NGHTTP2_ERR_INVALID_ARGUMENT
;
goto
fail
;
}
}
else
if
(
stream_id
==
pri_spec
->
stream_id
)
{
rv
=
NGHTTP2_ERR_INVALID_ARGUMENT
;
goto
fail
;
}
item
=
nghttp2_mem_malloc
(
mem
,
sizeof
(
nghttp2_outbound_item
));
item
=
nghttp2_mem_malloc
(
mem
,
sizeof
(
nghttp2_outbound_item
));
if
(
item
==
NULL
)
{
if
(
item
==
NULL
)
{
rv
=
NGHTTP2_ERR_NOMEM
;
rv
=
NGHTTP2_ERR_NOMEM
;
...
@@ -156,6 +170,10 @@ static int32_t submit_headers_shared_nva(nghttp2_session *session,
...
@@ -156,6 +170,10 @@ static int32_t submit_headers_shared_nva(nghttp2_session *session,
int
nghttp2_submit_trailer
(
nghttp2_session
*
session
,
int32_t
stream_id
,
int
nghttp2_submit_trailer
(
nghttp2_session
*
session
,
int32_t
stream_id
,
const
nghttp2_nv
*
nva
,
size_t
nvlen
)
{
const
nghttp2_nv
*
nva
,
size_t
nvlen
)
{
if
(
stream_id
<=
0
)
{
return
NGHTTP2_ERR_INVALID_ARGUMENT
;
}
return
(
int
)
submit_headers_shared_nva
(
session
,
NGHTTP2_FLAG_END_STREAM
,
return
(
int
)
submit_headers_shared_nva
(
session
,
NGHTTP2_FLAG_END_STREAM
,
stream_id
,
NULL
,
nva
,
nvlen
,
NULL
,
stream_id
,
NULL
,
nva
,
nvlen
,
NULL
,
NULL
);
NULL
);
...
@@ -166,9 +184,24 @@ int32_t nghttp2_submit_headers(nghttp2_session *session, uint8_t flags,
...
@@ -166,9 +184,24 @@ int32_t nghttp2_submit_headers(nghttp2_session *session, uint8_t flags,
const
nghttp2_priority_spec
*
pri_spec
,
const
nghttp2_priority_spec
*
pri_spec
,
const
nghttp2_nv
*
nva
,
size_t
nvlen
,
const
nghttp2_nv
*
nva
,
size_t
nvlen
,
void
*
stream_user_data
)
{
void
*
stream_user_data
)
{
int
rv
;
if
(
stream_id
==
-
1
)
{
if
(
session
->
server
)
{
return
NGHTTP2_ERR_PROTO
;
}
}
else
if
(
stream_id
<=
0
)
{
return
NGHTTP2_ERR_INVALID_ARGUMENT
;
}
flags
&=
NGHTTP2_FLAG_END_STREAM
;
flags
&=
NGHTTP2_FLAG_END_STREAM
;
if
(
pri_spec
&&
!
nghttp2_priority_spec_check_default
(
pri_spec
))
{
if
(
pri_spec
&&
!
nghttp2_priority_spec_check_default
(
pri_spec
))
{
rv
=
detect_self_dependency
(
session
,
stream_id
,
pri_spec
);
if
(
rv
!=
0
)
{
return
rv
;
}
flags
|=
NGHTTP2_FLAG_PRIORITY
;
flags
|=
NGHTTP2_FLAG_PRIORITY
;
}
else
{
}
else
{
pri_spec
=
NULL
;
pri_spec
=
NULL
;
...
@@ -281,7 +314,7 @@ int32_t nghttp2_submit_push_promise(nghttp2_session *session, uint8_t flags _U_,
...
@@ -281,7 +314,7 @@ int32_t nghttp2_submit_push_promise(nghttp2_session *session, uint8_t flags _U_,
mem
=
&
session
->
mem
;
mem
=
&
session
->
mem
;
if
(
stream_id
=
=
0
||
nghttp2_session_is_my_stream_id
(
session
,
stream_id
))
{
if
(
stream_id
<
=
0
||
nghttp2_session_is_my_stream_id
(
session
,
stream_id
))
{
return
NGHTTP2_ERR_INVALID_ARGUMENT
;
return
NGHTTP2_ERR_INVALID_ARGUMENT
;
}
}
...
@@ -396,8 +429,18 @@ int32_t nghttp2_submit_request(nghttp2_session *session,
...
@@ -396,8 +429,18 @@ int32_t nghttp2_submit_request(nghttp2_session *session,
const
nghttp2_data_provider
*
data_prd
,
const
nghttp2_data_provider
*
data_prd
,
void
*
stream_user_data
)
{
void
*
stream_user_data
)
{
uint8_t
flags
;
uint8_t
flags
;
int
rv
;
if
(
session
->
server
)
{
return
NGHTTP2_ERR_PROTO
;
}
if
(
pri_spec
&&
nghttp2_priority_spec_check_default
(
pri_spec
))
{
if
(
pri_spec
&&
!
nghttp2_priority_spec_check_default
(
pri_spec
))
{
rv
=
detect_self_dependency
(
session
,
-
1
,
pri_spec
);
if
(
rv
!=
0
)
{
return
rv
;
}
}
else
{
pri_spec
=
NULL
;
pri_spec
=
NULL
;
}
}
...
@@ -418,7 +461,17 @@ static uint8_t set_response_flags(const nghttp2_data_provider *data_prd) {
...
@@ -418,7 +461,17 @@ static uint8_t set_response_flags(const nghttp2_data_provider *data_prd) {
int
nghttp2_submit_response
(
nghttp2_session
*
session
,
int32_t
stream_id
,
int
nghttp2_submit_response
(
nghttp2_session
*
session
,
int32_t
stream_id
,
const
nghttp2_nv
*
nva
,
size_t
nvlen
,
const
nghttp2_nv
*
nva
,
size_t
nvlen
,
const
nghttp2_data_provider
*
data_prd
)
{
const
nghttp2_data_provider
*
data_prd
)
{
uint8_t
flags
=
set_response_flags
(
data_prd
);
uint8_t
flags
;
if
(
stream_id
<=
0
)
{
return
NGHTTP2_ERR_INVALID_ARGUMENT
;
}
if
(
!
session
->
server
)
{
return
NGHTTP2_ERR_PROTO
;
}
flags
=
set_response_flags
(
data_prd
);
return
submit_headers_shared_nva
(
session
,
flags
,
stream_id
,
NULL
,
nva
,
nvlen
,
return
submit_headers_shared_nva
(
session
,
flags
,
stream_id
,
NULL
,
nva
,
nvlen
,
data_prd
,
NULL
);
data_prd
,
NULL
);
}
}
...
...
tests/nghttp2_session_test.c
View file @
e14da859
...
@@ -759,9 +759,8 @@ void test_nghttp2_session_recv_data(void) {
...
@@ -759,9 +759,8 @@ void test_nghttp2_session_recv_data(void) {
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
&
ud
);
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
&
ud
);
/* Create stream 1 with CLOSING state. DATA is ignored. */
/* Create stream 1 with CLOSING state. DATA is ignored. */
stream
=
nghttp2_session_open_stream
(
session
,
1
,
NGHTTP2_STREAM_FLAG_NONE
,
stream
=
open_sent_stream2
(
session
,
1
,
NGHTTP2_STREAM_CLOSING
);
&
pri_spec_default
,
NGHTTP2_STREAM_CLOSING
,
NULL
);
/* Set initial window size 16383 to check stream flow control,
/* Set initial window size 16383 to check stream flow control,
isolating it from the conneciton flow control */
isolating it from the conneciton flow control */
stream
->
local_window_size
=
16383
;
stream
->
local_window_size
=
16383
;
...
@@ -848,7 +847,7 @@ void test_nghttp2_session_recv_data(void) {
...
@@ -848,7 +847,7 @@ void test_nghttp2_session_recv_data(void) {
hd
.
stream_id
=
1
;
hd
.
stream_id
=
1
;
nghttp2_frame_pack_frame_hd
(
data
,
&
hd
);
nghttp2_frame_pack_frame_hd
(
data
,
&
hd
);
stream
=
open_stream
(
session
,
1
);
stream
=
open_
recv_
stream
(
session
,
1
);
/* Send 32767 bytes of DATA. In our current flow control algorithm,
/* Send 32767 bytes of DATA. In our current flow control algorithm,
it triggers first WINDOW_UPDATE of window_size_increment
it triggers first WINDOW_UPDATE of window_size_increment
...
@@ -936,7 +935,7 @@ void test_nghttp2_session_recv_data_no_auto_flow_control(void) {
...
@@ -936,7 +935,7 @@ void test_nghttp2_session_recv_data_no_auto_flow_control(void) {
/* First create stream 1, then close it. Check that data is
/* First create stream 1, then close it. Check that data is
consumed for connection in this situation */
consumed for connection in this situation */
open_stream
(
session
,
1
);
open_
recv_
stream
(
session
,
1
);
/* Receive first 100 bytes */
/* Receive first 100 bytes */
sendlen
=
100
;
sendlen
=
100
;
...
@@ -968,7 +967,7 @@ void test_nghttp2_session_recv_data_no_auto_flow_control(void) {
...
@@ -968,7 +967,7 @@ void test_nghttp2_session_recv_data_no_auto_flow_control(void) {
/* Now we are expecting final response header, which means receiving
/* Now we are expecting final response header, which means receiving
DATA for that stream is illegal. */
DATA for that stream is illegal. */
stream
=
open_stream
(
session
,
1
);
stream
=
open_
recv_
stream
(
session
,
1
);
stream
->
http_flags
|=
NGHTTP2_HTTP_FLAG_EXPECT_FINAL_RESPONSE
;
stream
->
http_flags
|=
NGHTTP2_HTTP_FLAG_EXPECT_FINAL_RESPONSE
;
rv
=
nghttp2_session_mem_recv
(
session
,
data
,
NGHTTP2_FRAME_HDLEN
+
hd
.
length
);
rv
=
nghttp2_session_mem_recv
(
session
,
data
,
NGHTTP2_FRAME_HDLEN
+
hd
.
length
);
...
@@ -983,7 +982,7 @@ void test_nghttp2_session_recv_data_no_auto_flow_control(void) {
...
@@ -983,7 +982,7 @@ void test_nghttp2_session_recv_data_no_auto_flow_control(void) {
/* Check window_update_queued flag in both session and stream */
/* Check window_update_queued flag in both session and stream */
nghttp2_session_server_new2
(
&
session
,
&
callbacks
,
&
ud
,
option
);
nghttp2_session_server_new2
(
&
session
,
&
callbacks
,
&
ud
,
option
);
stream
=
open_stream
(
session
,
1
);
stream
=
open_
recv_
stream
(
session
,
1
);
hd
.
length
=
4096
;
hd
.
length
=
4096
;
hd
.
type
=
NGHTTP2_DATA
;
hd
.
type
=
NGHTTP2_DATA
;
...
@@ -1271,7 +1270,7 @@ void test_nghttp2_session_recv_headers_with_priority(void) {
...
@@ -1271,7 +1270,7 @@ void test_nghttp2_session_recv_headers_with_priority(void) {
nghttp2_hd_deflate_init
(
&
deflater
,
mem
);
nghttp2_hd_deflate_init
(
&
deflater
,
mem
);
open_stream
(
session
,
1
);
open_
recv_
stream
(
session
,
1
);
/* With NGHTTP2_FLAG_PRIORITY without exclusive flag set */
/* With NGHTTP2_FLAG_PRIORITY without exclusive flag set */
nvlen
=
ARRLEN
(
reqnv
);
nvlen
=
ARRLEN
(
reqnv
);
...
@@ -1500,8 +1499,7 @@ void test_nghttp2_session_server_recv_push_response(void) {
...
@@ -1500,8 +1499,7 @@ void test_nghttp2_session_server_recv_push_response(void) {
nghttp2_hd_deflate_init
(
&
deflater
,
mem
);
nghttp2_hd_deflate_init
(
&
deflater
,
mem
);
nghttp2_session_open_stream
(
session
,
2
,
NGHTTP2_STREAM_FLAG_NONE
,
open_sent_stream2
(
session
,
2
,
NGHTTP2_STREAM_RESERVED
);
&
pri_spec_default
,
NGHTTP2_STREAM_RESERVED
,
NULL
);
nvlen
=
ARRLEN
(
resnv
);
nvlen
=
ARRLEN
(
resnv
);
nghttp2_nv_array_copy
(
&
nva
,
resnv
,
nvlen
,
mem
);
nghttp2_nv_array_copy
(
&
nva
,
resnv
,
nvlen
,
mem
);
...
@@ -1578,8 +1576,8 @@ void test_nghttp2_session_recv_premature_headers(void) {
...
@@ -1578,8 +1576,8 @@ void test_nghttp2_session_recv_premature_headers(void) {
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
&
ud
);
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
&
ud
);
nghttp2_hd_deflate_init
(
&
deflater
,
mem
);
nghttp2_hd_deflate_init
(
&
deflater
,
mem
);
nghttp2_session_open_stream
(
session
,
1
,
NGHTTP2_STREAM_FLAG_NONE
,
open_sent_stream3
(
session
,
1
,
NGHTTP2_STREAM_FLAG_NONE
,
&
pri_spec_default
,
&
pri_spec_default
,
NGHTTP2_STREAM_OPENING
,
NULL
);
NGHTTP2_STREAM_OPENING
,
NULL
);
rv
=
pack_push_promise
(
&
bufs
,
&
deflater
,
1
,
NGHTTP2_FLAG_END_HEADERS
,
2
,
rv
=
pack_push_promise
(
&
bufs
,
&
deflater
,
1
,
NGHTTP2_FLAG_END_HEADERS
,
2
,
reqnv
,
ARRLEN
(
reqnv
),
mem
);
reqnv
,
ARRLEN
(
reqnv
),
mem
);
...
@@ -1659,7 +1657,7 @@ void test_nghttp2_session_recv_unexpected_continuation(void) {
...
@@ -1659,7 +1657,7 @@ void test_nghttp2_session_recv_unexpected_continuation(void) {
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
&
ud
);
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
&
ud
);
open_stream
(
session
,
1
);
open_
recv_
stream
(
session
,
1
);
ud
.
frame_recv_cb_called
=
0
;
ud
.
frame_recv_cb_called
=
0
;
...
@@ -2329,6 +2327,7 @@ void test_nghttp2_session_on_request_headers_received(void) {
...
@@ -2329,6 +2327,7 @@ void test_nghttp2_session_on_request_headers_received(void) {
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
&
user_data
);
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
&
user_data
);
session
->
next_stream_id
=
5
;
session
->
next_stream_id
=
5
;
session
->
sent_stream_id
=
3
;
/* Stream ID which is not idle and not in stream map is just
/* Stream ID which is not idle and not in stream map is just
ignored */
ignored */
...
@@ -2375,8 +2374,7 @@ void test_nghttp2_session_on_request_headers_received(void) {
...
@@ -2375,8 +2374,7 @@ void test_nghttp2_session_on_request_headers_received(void) {
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
&
user_data
);
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
&
user_data
);
/* HEADERS to closed stream */
/* HEADERS to closed stream */
stream
=
open_stream
(
session
,
1
);
stream
=
open_recv_stream
(
session
,
1
);
session
->
last_recv_stream_id
=
1
;
nghttp2_stream_shutdown
(
stream
,
NGHTTP2_SHUT_RD
);
nghttp2_stream_shutdown
(
stream
,
NGHTTP2_SHUT_RD
);
nghttp2_session_close_stream
(
session
,
1
,
NGHTTP2_NO_ERROR
);
nghttp2_session_close_stream
(
session
,
1
,
NGHTTP2_NO_ERROR
);
...
@@ -2406,9 +2404,7 @@ void test_nghttp2_session_on_response_headers_received(void) {
...
@@ -2406,9 +2404,7 @@ void test_nghttp2_session_on_response_headers_received(void) {
callbacks
.
on_invalid_frame_recv_callback
=
on_invalid_frame_recv_callback
;
callbacks
.
on_invalid_frame_recv_callback
=
on_invalid_frame_recv_callback
;
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
&
user_data
);
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
&
user_data
);
stream
=
nghttp2_session_open_stream
(
session
,
1
,
NGHTTP2_STREAM_FLAG_NONE
,
stream
=
open_sent_stream2
(
session
,
1
,
NGHTTP2_STREAM_OPENING
);
&
pri_spec_default
,
NGHTTP2_STREAM_OPENING
,
NULL
);
nghttp2_frame_headers_init
(
&
frame
.
headers
,
NGHTTP2_FLAG_END_HEADERS
,
1
,
nghttp2_frame_headers_init
(
&
frame
.
headers
,
NGHTTP2_FLAG_END_HEADERS
,
1
,
NGHTTP2_HCAT_HEADERS
,
NULL
,
NULL
,
0
);
NGHTTP2_HCAT_HEADERS
,
NULL
,
NULL
,
0
);
...
@@ -2438,9 +2434,7 @@ void test_nghttp2_session_on_headers_received(void) {
...
@@ -2438,9 +2434,7 @@ void test_nghttp2_session_on_headers_received(void) {
callbacks
.
on_invalid_frame_recv_callback
=
on_invalid_frame_recv_callback
;
callbacks
.
on_invalid_frame_recv_callback
=
on_invalid_frame_recv_callback
;
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
&
user_data
);
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
&
user_data
);
stream
=
nghttp2_session_open_stream
(
session
,
1
,
NGHTTP2_STREAM_FLAG_NONE
,
stream
=
open_sent_stream2
(
session
,
1
,
NGHTTP2_STREAM_OPENED
);
&
pri_spec_default
,
NGHTTP2_STREAM_OPENED
,
NULL
);
nghttp2_stream_shutdown
(
stream
,
NGHTTP2_SHUT_WR
);
nghttp2_stream_shutdown
(
stream
,
NGHTTP2_SHUT_WR
);
nghttp2_frame_headers_init
(
&
frame
.
headers
,
NGHTTP2_FLAG_END_HEADERS
,
1
,
nghttp2_frame_headers_init
(
&
frame
.
headers
,
NGHTTP2_FLAG_END_HEADERS
,
1
,
NGHTTP2_HCAT_HEADERS
,
NULL
,
NULL
,
0
);
NGHTTP2_HCAT_HEADERS
,
NULL
,
NULL
,
0
);
...
@@ -2460,9 +2454,7 @@ void test_nghttp2_session_on_headers_received(void) {
...
@@ -2460,9 +2454,7 @@ void test_nghttp2_session_on_headers_received(void) {
/* Check to see when NGHTTP2_STREAM_CLOSING, incoming HEADERS is
/* Check to see when NGHTTP2_STREAM_CLOSING, incoming HEADERS is
discarded. */
discarded. */
stream
=
nghttp2_session_open_stream
(
session
,
3
,
NGHTTP2_STREAM_FLAG_NONE
,
stream
=
open_sent_stream2
(
session
,
3
,
NGHTTP2_STREAM_CLOSING
);
&
pri_spec_default
,
NGHTTP2_STREAM_CLOSING
,
NULL
);
frame
.
hd
.
stream_id
=
3
;
frame
.
hd
.
stream_id
=
3
;
frame
.
hd
.
flags
=
NGHTTP2_FLAG_END_HEADERS
;
frame
.
hd
.
flags
=
NGHTTP2_FLAG_END_HEADERS
;
CU_ASSERT
(
NGHTTP2_ERR_IGN_HEADER_BLOCK
==
CU_ASSERT
(
NGHTTP2_ERR_IGN_HEADER_BLOCK
==
...
@@ -2472,17 +2464,14 @@ void test_nghttp2_session_on_headers_received(void) {
...
@@ -2472,17 +2464,14 @@ void test_nghttp2_session_on_headers_received(void) {
CU_ASSERT
(
0
==
user_data
.
invalid_frame_recv_cb_called
);
CU_ASSERT
(
0
==
user_data
.
invalid_frame_recv_cb_called
);
/* Server initiated stream */
/* Server initiated stream */
stream
=
nghttp2_session_open_stream
(
session
,
2
,
NGHTTP2_STREAM_FLAG_NONE
,
stream
=
open_recv_stream
(
session
,
2
);
&
pri_spec_default
,
NGHTTP2_STREAM_OPENING
,
NULL
);
/* half closed (remote) */
frame
.
hd
.
flags
=
NGHTTP2_FLAG_END_HEADERS
|
NGHTTP2_FLAG_END_STREAM
;
frame
.
hd
.
flags
=
NGHTTP2_FLAG_END_HEADERS
|
NGHTTP2_FLAG_END_STREAM
;
frame
.
hd
.
stream_id
=
2
;
frame
.
hd
.
stream_id
=
2
;
CU_ASSERT
(
0
==
nghttp2_session_on_headers_received
(
session
,
&
frame
,
stream
));
CU_ASSERT
(
0
==
nghttp2_session_on_headers_received
(
session
,
&
frame
,
stream
));
CU_ASSERT
(
3
==
user_data
.
begin_headers_cb_called
);
CU_ASSERT
(
3
==
user_data
.
begin_headers_cb_called
);
CU_ASSERT
(
NGHTTP2_STREAM_OPEN
ING
==
stream
->
state
);
CU_ASSERT
(
NGHTTP2_STREAM_OPEN
ED
==
stream
->
state
);
nghttp2_stream_shutdown
(
stream
,
NGHTTP2_SHUT_RD
);
nghttp2_stream_shutdown
(
stream
,
NGHTTP2_SHUT_RD
);
...
@@ -2512,9 +2501,7 @@ void test_nghttp2_session_on_push_response_headers_received(void) {
...
@@ -2512,9 +2501,7 @@ void test_nghttp2_session_on_push_response_headers_received(void) {
callbacks
.
on_invalid_frame_recv_callback
=
on_invalid_frame_recv_callback
;
callbacks
.
on_invalid_frame_recv_callback
=
on_invalid_frame_recv_callback
;
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
&
user_data
);
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
&
user_data
);
stream
=
nghttp2_session_open_stream
(
session
,
2
,
NGHTTP2_STREAM_FLAG_NONE
,
stream
=
open_recv_stream2
(
session
,
2
,
NGHTTP2_STREAM_RESERVED
);
&
pri_spec_default
,
NGHTTP2_STREAM_RESERVED
,
NULL
);
nghttp2_frame_headers_init
(
&
frame
.
headers
,
NGHTTP2_FLAG_END_HEADERS
,
2
,
nghttp2_frame_headers_init
(
&
frame
.
headers
,
NGHTTP2_FLAG_END_HEADERS
,
2
,
NGHTTP2_HCAT_HEADERS
,
NULL
,
NULL
,
0
);
NGHTTP2_HCAT_HEADERS
,
NULL
,
NULL
,
0
);
/* nghttp2_session_on_push_response_headers_received assumes
/* nghttp2_session_on_push_response_headers_received assumes
...
@@ -2536,9 +2523,7 @@ void test_nghttp2_session_on_push_response_headers_received(void) {
...
@@ -2536,9 +2523,7 @@ void test_nghttp2_session_on_push_response_headers_received(void) {
/* If un-ACKed max concurrent streams limit is exceeded,
/* If un-ACKed max concurrent streams limit is exceeded,
RST_STREAMed */
RST_STREAMed */
session
->
pending_local_max_concurrent_stream
=
1
;
session
->
pending_local_max_concurrent_stream
=
1
;
stream
=
nghttp2_session_open_stream
(
session
,
4
,
NGHTTP2_STREAM_FLAG_NONE
,
stream
=
open_recv_stream2
(
session
,
4
,
NGHTTP2_STREAM_RESERVED
);
&
pri_spec_default
,
NGHTTP2_STREAM_RESERVED
,
NULL
);
frame
.
hd
.
stream_id
=
4
;
frame
.
hd
.
stream_id
=
4
;
CU_ASSERT
(
NGHTTP2_ERR_IGN_HEADER_BLOCK
==
CU_ASSERT
(
NGHTTP2_ERR_IGN_HEADER_BLOCK
==
nghttp2_session_on_push_response_headers_received
(
session
,
&
frame
,
nghttp2_session_on_push_response_headers_received
(
session
,
&
frame
,
...
@@ -2556,9 +2541,7 @@ void test_nghttp2_session_on_push_response_headers_received(void) {
...
@@ -2556,9 +2541,7 @@ void test_nghttp2_session_on_push_response_headers_received(void) {
issued */
issued */
session
->
local_settings
.
max_concurrent_streams
=
1
;
session
->
local_settings
.
max_concurrent_streams
=
1
;
stream
=
nghttp2_session_open_stream
(
session
,
6
,
NGHTTP2_STREAM_FLAG_NONE
,
stream
=
open_recv_stream2
(
session
,
6
,
NGHTTP2_STREAM_RESERVED
);
&
pri_spec_default
,
NGHTTP2_STREAM_RESERVED
,
NULL
);
frame
.
hd
.
stream_id
=
6
;
frame
.
hd
.
stream_id
=
6
;
CU_ASSERT
(
NGHTTP2_ERR_IGN_HEADER_BLOCK
==
CU_ASSERT
(
NGHTTP2_ERR_IGN_HEADER_BLOCK
==
...
@@ -2588,9 +2571,7 @@ void test_nghttp2_session_on_priority_received(void) {
...
@@ -2588,9 +2571,7 @@ void test_nghttp2_session_on_priority_received(void) {
callbacks
.
on_invalid_frame_recv_callback
=
on_invalid_frame_recv_callback
;
callbacks
.
on_invalid_frame_recv_callback
=
on_invalid_frame_recv_callback
;
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
&
user_data
);
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
&
user_data
);
stream
=
nghttp2_session_open_stream
(
session
,
1
,
NGHTTP2_STREAM_FLAG_NONE
,
stream
=
open_recv_stream
(
session
,
1
);
&
pri_spec_default
,
NGHTTP2_STREAM_OPENING
,
NULL
);
nghttp2_priority_spec_init
(
&
pri_spec
,
0
,
2
,
0
);
nghttp2_priority_spec_init
(
&
pri_spec
,
0
,
2
,
0
);
...
@@ -2601,13 +2582,8 @@ void test_nghttp2_session_on_priority_received(void) {
...
@@ -2601,13 +2582,8 @@ void test_nghttp2_session_on_priority_received(void) {
CU_ASSERT
(
2
==
stream
->
weight
);
CU_ASSERT
(
2
==
stream
->
weight
);
stream
=
nghttp2_session_open_stream
(
session
,
2
,
NGHTTP2_STREAM_FLAG_NONE
,
stream
=
open_sent_stream
(
session
,
2
);
&
pri_spec_default
,
dep_stream
=
open_recv_stream
(
session
,
3
);
NGHTTP2_STREAM_OPENING
,
NULL
);
dep_stream
=
nghttp2_session_open_stream
(
session
,
3
,
NGHTTP2_STREAM_FLAG_NONE
,
&
pri_spec_default
,
NGHTTP2_STREAM_OPENING
,
NULL
);
frame
.
hd
.
stream_id
=
2
;
frame
.
hd
.
stream_id
=
2
;
...
@@ -2633,8 +2609,7 @@ void test_nghttp2_session_on_priority_received(void) {
...
@@ -2633,8 +2609,7 @@ void test_nghttp2_session_on_priority_received(void) {
/* Check dep_stream_id == stream_id case */
/* Check dep_stream_id == stream_id case */
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
&
user_data
);
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
&
user_data
);
nghttp2_session_open_stream
(
session
,
1
,
NGHTTP2_STREAM_FLAG_NONE
,
open_recv_stream
(
session
,
1
);
&
pri_spec_default
,
NGHTTP2_STREAM_OPENED
,
NULL
);
nghttp2_priority_spec_init
(
&
pri_spec
,
1
,
0
,
0
);
nghttp2_priority_spec_init
(
&
pri_spec
,
1
,
0
,
0
);
...
@@ -2673,8 +2648,7 @@ void test_nghttp2_session_on_rst_stream_received(void) {
...
@@ -2673,8 +2648,7 @@ void test_nghttp2_session_on_rst_stream_received(void) {
nghttp2_frame
frame
;
nghttp2_frame
frame
;
memset
(
&
callbacks
,
0
,
sizeof
(
nghttp2_session_callbacks
));
memset
(
&
callbacks
,
0
,
sizeof
(
nghttp2_session_callbacks
));
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
&
user_data
);
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
&
user_data
);
nghttp2_session_open_stream
(
session
,
1
,
NGHTTP2_STREAM_FLAG_NONE
,
open_recv_stream
(
session
,
1
);
&
pri_spec_default
,
NGHTTP2_STREAM_OPENING
,
NULL
);
nghttp2_frame_rst_stream_init
(
&
frame
.
rst_stream
,
1
,
NGHTTP2_PROTOCOL_ERROR
);
nghttp2_frame_rst_stream_init
(
&
frame
.
rst_stream
,
1
,
NGHTTP2_PROTOCOL_ERROR
);
...
@@ -2720,12 +2694,9 @@ void test_nghttp2_session_on_settings_received(void) {
...
@@ -2720,12 +2694,9 @@ void test_nghttp2_session_on_settings_received(void) {
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
&
user_data
);
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
&
user_data
);
session
->
remote_settings
.
initial_window_size
=
16
*
1024
;
session
->
remote_settings
.
initial_window_size
=
16
*
1024
;
stream1
=
nghttp2_session_open_stream
(
session
,
1
,
NGHTTP2_STREAM_FLAG_NONE
,
stream1
=
open_sent_stream
(
session
,
1
);
&
pri_spec_default
,
stream2
=
open_recv_stream
(
session
,
2
);
NGHTTP2_STREAM_OPENING
,
NULL
);
stream2
=
nghttp2_session_open_stream
(
session
,
2
,
NGHTTP2_STREAM_FLAG_NONE
,
&
pri_spec_default
,
NGHTTP2_STREAM_OPENING
,
NULL
);
/* Set window size for each streams and will see how settings
/* Set window size for each streams and will see how settings
updates these values */
updates these values */
stream1
->
remote_window_size
=
16
*
1024
;
stream1
->
remote_window_size
=
16
*
1024
;
...
@@ -2852,9 +2823,8 @@ void test_nghttp2_session_on_push_promise_received(void) {
...
@@ -2852,9 +2823,8 @@ void test_nghttp2_session_on_push_promise_received(void) {
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
&
user_data
);
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
&
user_data
);
stream
=
nghttp2_session_open_stream
(
session
,
1
,
NGHTTP2_STREAM_FLAG_NONE
,
stream
=
open_sent_stream
(
session
,
1
);
&
pri_spec_default
,
NGHTTP2_STREAM_OPENING
,
NULL
);
nghttp2_frame_push_promise_init
(
&
frame
.
push_promise
,
NGHTTP2_FLAG_END_HEADERS
,
nghttp2_frame_push_promise_init
(
&
frame
.
push_promise
,
NGHTTP2_FLAG_END_HEADERS
,
1
,
2
,
NULL
,
0
);
1
,
2
,
NULL
,
0
);
...
@@ -2892,9 +2862,7 @@ void test_nghttp2_session_on_push_promise_received(void) {
...
@@ -2892,9 +2862,7 @@ void test_nghttp2_session_on_push_promise_received(void) {
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
&
user_data
);
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
&
user_data
);
stream
=
nghttp2_session_open_stream
(
session
,
1
,
NGHTTP2_STREAM_FLAG_NONE
,
stream
=
open_sent_stream
(
session
,
1
);
&
pri_spec_default
,
NGHTTP2_STREAM_OPENING
,
NULL
);
/* Attempt to PUSH_PROMISE against stream in closing state */
/* Attempt to PUSH_PROMISE against stream in closing state */
stream
->
state
=
NGHTTP2_STREAM_CLOSING
;
stream
->
state
=
NGHTTP2_STREAM_CLOSING
;
...
@@ -2936,9 +2904,7 @@ void test_nghttp2_session_on_push_promise_received(void) {
...
@@ -2936,9 +2904,7 @@ void test_nghttp2_session_on_push_promise_received(void) {
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
&
user_data
);
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
&
user_data
);
stream
=
nghttp2_session_open_stream
(
session
,
1
,
NGHTTP2_STREAM_FLAG_NONE
,
stream
=
open_sent_stream
(
session
,
1
);
&
pri_spec_default
,
NGHTTP2_STREAM_OPENING
,
NULL
);
/* Same ID twice */
/* Same ID twice */
frame
.
hd
.
stream_id
=
1
;
frame
.
hd
.
stream_id
=
1
;
...
@@ -2983,8 +2949,8 @@ void test_nghttp2_session_on_push_promise_received(void) {
...
@@ -2983,8 +2949,8 @@ void test_nghttp2_session_on_push_promise_received(void) {
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
&
user_data
);
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
&
user_data
);
nghttp2_session_open_stream
(
session
,
2
,
NGHTTP2_STREAM_FLAG_NONE
,
open_recv_stream2
(
session
,
2
,
NGHTTP2_STREAM_RESERVED
);
&
pri_spec_default
,
NGHTTP2_STREAM_RESERVED
,
NULL
);
/* Attempt to PUSH_PROMISE against reserved (remote) stream */
/* Attempt to PUSH_PROMISE against reserved (remote) stream */
nghttp2_frame_push_promise_init
(
&
frame
.
push_promise
,
NGHTTP2_FLAG_END_HEADERS
,
nghttp2_frame_push_promise_init
(
&
frame
.
push_promise
,
NGHTTP2_FLAG_END_HEADERS
,
2
,
4
,
NULL
,
0
);
2
,
4
,
NULL
,
0
);
...
@@ -3004,8 +2970,7 @@ void test_nghttp2_session_on_push_promise_received(void) {
...
@@ -3004,8 +2970,7 @@ void test_nghttp2_session_on_push_promise_received(void) {
/* Disable PUSH */
/* Disable PUSH */
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
&
user_data
);
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
&
user_data
);
nghttp2_session_open_stream
(
session
,
1
,
NGHTTP2_STREAM_FLAG_NONE
,
open_sent_stream
(
session
,
1
);
&
pri_spec_default
,
NGHTTP2_STREAM_OPENING
,
NULL
);
session
->
local_settings
.
enable_push
=
0
;
session
->
local_settings
.
enable_push
=
0
;
...
@@ -3027,8 +2992,8 @@ void test_nghttp2_session_on_push_promise_received(void) {
...
@@ -3027,8 +2992,8 @@ void test_nghttp2_session_on_push_promise_received(void) {
/* Check malformed headers. We accept malformed headers */
/* Check malformed headers. We accept malformed headers */
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
&
user_data
);
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
&
user_data
);
nghttp2_session_open_stream
(
session
,
1
,
NGHTTP2_STREAM_FLAG_NONE
,
open_sent_stream
(
session
,
1
);
&
pri_spec_default
,
NGHTTP2_STREAM_OPENING
,
NULL
);
nvlen
=
ARRLEN
(
malformed_nva
);
nvlen
=
ARRLEN
(
malformed_nva
);
nghttp2_nv_array_copy
(
&
nva
,
malformed_nva
,
nvlen
,
mem
);
nghttp2_nv_array_copy
(
&
nva
,
malformed_nva
,
nvlen
,
mem
);
nghttp2_frame_push_promise_init
(
&
frame
.
push_promise
,
NGHTTP2_FLAG_END_HEADERS
,
nghttp2_frame_push_promise_init
(
&
frame
.
push_promise
,
NGHTTP2_FLAG_END_HEADERS
,
...
@@ -3047,8 +3012,8 @@ void test_nghttp2_session_on_push_promise_received(void) {
...
@@ -3047,8 +3012,8 @@ void test_nghttp2_session_on_push_promise_received(void) {
peer, incoming PUSH_PROMISE is rejected */
peer, incoming PUSH_PROMISE is rejected */
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
&
user_data
);
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
&
user_data
);
nghttp2_session_open_stream
(
session
,
1
,
NGHTTP2_STREAM_FLAG_NONE
,
open_sent_stream
(
session
,
1
);
&
pri_spec_default
,
NGHTTP2_STREAM_OPENING
,
NULL
);
/* Submit settings with ENABLE_PUSH = 0 (thus disabling push) */
/* Submit settings with ENABLE_PUSH = 0 (thus disabling push) */
nghttp2_submit_settings
(
session
,
NGHTTP2_FLAG_NONE
,
&
iv
,
1
);
nghttp2_submit_settings
(
session
,
NGHTTP2_FLAG_NONE
,
&
iv
,
1
);
...
@@ -3067,10 +3032,8 @@ void test_nghttp2_session_on_push_promise_received(void) {
...
@@ -3067,10 +3032,8 @@ void test_nghttp2_session_on_push_promise_received(void) {
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
&
user_data
);
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
&
user_data
);
session
->
max_incoming_reserved_streams
=
1
;
session
->
max_incoming_reserved_streams
=
1
;
nghttp2_session_open_stream
(
session
,
1
,
NGHTTP2_STREAM_FLAG_NONE
,
open_sent_stream
(
session
,
1
);
&
pri_spec_default
,
NGHTTP2_STREAM_OPENING
,
NULL
);
open_recv_stream2
(
session
,
2
,
NGHTTP2_STREAM_RESERVED
);
nghttp2_session_open_stream
(
session
,
2
,
NGHTTP2_STREAM_FLAG_NONE
,
&
pri_spec_default
,
NGHTTP2_STREAM_RESERVED
,
NULL
);
CU_ASSERT
(
1
==
session
->
num_incoming_reserved_streams
);
CU_ASSERT
(
1
==
session
->
num_incoming_reserved_streams
);
...
@@ -3150,7 +3113,11 @@ void test_nghttp2_session_on_goaway_received(void) {
...
@@ -3150,7 +3113,11 @@ void test_nghttp2_session_on_goaway_received(void) {
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
&
user_data
);
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
&
user_data
);
for
(
i
=
1
;
i
<=
7
;
++
i
)
{
for
(
i
=
1
;
i
<=
7
;
++
i
)
{
open_stream
(
session
,
i
);
if
(
nghttp2_session_is_my_stream_id
(
session
,
i
))
{
open_sent_stream
(
session
,
i
);
}
else
{
open_recv_stream
(
session
,
i
);
}
}
}
nghttp2_frame_goaway_init
(
&
frame
.
goaway
,
3
,
NGHTTP2_PROTOCOL_ERROR
,
NULL
,
0
);
nghttp2_frame_goaway_init
(
&
frame
.
goaway
,
3
,
NGHTTP2_PROTOCOL_ERROR
,
NULL
,
0
);
...
@@ -3195,9 +3162,7 @@ void test_nghttp2_session_on_window_update_received(void) {
...
@@ -3195,9 +3162,7 @@ void test_nghttp2_session_on_window_update_received(void) {
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
&
user_data
);
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
&
user_data
);
stream
=
nghttp2_session_open_stream
(
session
,
1
,
NGHTTP2_STREAM_FLAG_NONE
,
stream
=
open_sent_stream
(
session
,
1
);
&
pri_spec_default
,
NGHTTP2_STREAM_OPENED
,
NULL
);
data_item
=
create_data_ob_item
(
mem
);
data_item
=
create_data_ob_item
(
mem
);
...
@@ -3224,8 +3189,7 @@ void test_nghttp2_session_on_window_update_received(void) {
...
@@ -3224,8 +3189,7 @@ void test_nghttp2_session_on_window_update_received(void) {
/* Receiving WINDOW_UPDATE on reserved (remote) stream is a
/* Receiving WINDOW_UPDATE on reserved (remote) stream is a
connection error */
connection error */
nghttp2_session_open_stream
(
session
,
2
,
NGHTTP2_STREAM_FLAG_NONE
,
open_recv_stream2
(
session
,
2
,
NGHTTP2_STREAM_RESERVED
);
&
pri_spec_default
,
NGHTTP2_STREAM_RESERVED
,
NULL
);
nghttp2_frame_window_update_init
(
&
frame
.
window_update
,
NGHTTP2_FLAG_NONE
,
2
,
nghttp2_frame_window_update_init
(
&
frame
.
window_update
,
NGHTTP2_FLAG_NONE
,
2
,
4096
);
4096
);
...
@@ -3241,9 +3205,7 @@ void test_nghttp2_session_on_window_update_received(void) {
...
@@ -3241,9 +3205,7 @@ void test_nghttp2_session_on_window_update_received(void) {
/* Receiving WINDOW_UPDATE on reserved (local) stream is allowed */
/* Receiving WINDOW_UPDATE on reserved (local) stream is allowed */
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
&
user_data
);
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
&
user_data
);
stream
=
nghttp2_session_open_stream
(
session
,
2
,
NGHTTP2_STREAM_FLAG_NONE
,
stream
=
open_sent_stream2
(
session
,
2
,
NGHTTP2_STREAM_RESERVED
);
&
pri_spec_default
,
NGHTTP2_STREAM_RESERVED
,
NULL
);
nghttp2_frame_window_update_init
(
&
frame
.
window_update
,
NGHTTP2_FLAG_NONE
,
2
,
nghttp2_frame_window_update_init
(
&
frame
.
window_update
,
NGHTTP2_FLAG_NONE
,
2
,
4096
);
4096
);
...
@@ -3269,9 +3231,7 @@ void test_nghttp2_session_on_data_received(void) {
...
@@ -3269,9 +3231,7 @@ void test_nghttp2_session_on_data_received(void) {
memset
(
&
callbacks
,
0
,
sizeof
(
nghttp2_session_callbacks
));
memset
(
&
callbacks
,
0
,
sizeof
(
nghttp2_session_callbacks
));
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
&
user_data
);
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
&
user_data
);
stream
=
nghttp2_session_open_stream
(
session
,
2
,
NGHTTP2_STREAM_FLAG_NONE
,
stream
=
open_recv_stream
(
session
,
2
);
&
pri_spec_default
,
NGHTTP2_STREAM_OPENING
,
NULL
);
nghttp2_frame_hd_init
(
&
frame
.
hd
,
4096
,
NGHTTP2_DATA
,
NGHTTP2_FLAG_NONE
,
2
);
nghttp2_frame_hd_init
(
&
frame
.
hd
,
4096
,
NGHTTP2_DATA
,
NGHTTP2_FLAG_NONE
,
2
);
...
@@ -3284,11 +3244,10 @@ void test_nghttp2_session_on_data_received(void) {
...
@@ -3284,11 +3244,10 @@ void test_nghttp2_session_on_data_received(void) {
CU_ASSERT
(
NGHTTP2_SHUT_RD
==
stream
->
shut_flags
);
CU_ASSERT
(
NGHTTP2_SHUT_RD
==
stream
->
shut_flags
);
/* If NGHTTP2_STREAM_CLOSING state, DATA frame is discarded. */
/* If NGHTTP2_STREAM_CLOSING state, DATA frame is discarded. */
nghttp2_session_open_stream
(
session
,
4
,
NGHTTP2_STREAM_FLAG_NONE
,
open_sent_stream2
(
session
,
1
,
NGHTTP2_STREAM_CLOSING
);
&
pri_spec_default
,
NGHTTP2_STREAM_CLOSING
,
NULL
);
frame
.
hd
.
flags
=
NGHTTP2_FLAG_NONE
;
frame
.
hd
.
flags
=
NGHTTP2_FLAG_NONE
;
frame
.
hd
.
stream_id
=
4
;
frame
.
hd
.
stream_id
=
1
;
CU_ASSERT
(
0
==
nghttp2_session_on_data_received
(
session
,
&
frame
));
CU_ASSERT
(
0
==
nghttp2_session_on_data_received
(
session
,
&
frame
));
CU_ASSERT
(
NULL
==
nghttp2_outbound_queue_top
(
&
session
->
ob_reg
));
CU_ASSERT
(
NULL
==
nghttp2_outbound_queue_top
(
&
session
->
ob_reg
));
...
@@ -3296,14 +3255,12 @@ void test_nghttp2_session_on_data_received(void) {
...
@@ -3296,14 +3255,12 @@ void test_nghttp2_session_on_data_received(void) {
/* Check INVALID_STREAM case: DATA frame with stream ID which does
/* Check INVALID_STREAM case: DATA frame with stream ID which does
not exist. */
not exist. */
frame
.
hd
.
stream_id
=
6
;
frame
.
hd
.
stream_id
=
3
;
CU_ASSERT
(
0
==
nghttp2_session_on_data_received
(
session
,
&
frame
));
CU_ASSERT
(
0
==
nghttp2_session_on_data_received
(
session
,
&
frame
));
top
=
nghttp2_outbound_queue_top
(
&
session
->
ob_reg
);
top
=
nghttp2_outbound_queue_top
(
&
session
->
ob_reg
);
/* DATA against nonexistent stream is just ignored for now */
/* DATA against nonexistent stream is just ignored for now
.
*/
CU_ASSERT
(
top
==
NULL
);
CU_ASSERT
(
top
==
NULL
);
/* CU_ASSERT(NGHTTP2_RST_STREAM == top->frame.hd.type); */
/* CU_ASSERT(NGHTTP2_PROTOCOL_ERROR == top->frame.rst_stream.error_code); */
nghttp2_session_del
(
session
);
nghttp2_session_del
(
session
);
}
}
...
@@ -3324,7 +3281,7 @@ void test_nghttp2_session_on_data_received_fail_fast(void) {
...
@@ -3324,7 +3281,7 @@ void test_nghttp2_session_on_data_received_fail_fast(void) {
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
NULL
);
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
NULL
);
/* DATA to closed (remote) */
/* DATA to closed (remote) */
stream
=
open_stream
(
session
,
1
);
stream
=
open_
recv_
stream
(
session
,
1
);
nghttp2_stream_shutdown
(
stream
,
NGHTTP2_SHUT_RD
);
nghttp2_stream_shutdown
(
stream
,
NGHTTP2_SHUT_RD
);
CU_ASSERT
((
ssize_t
)
sizeof
(
buf
)
==
CU_ASSERT
((
ssize_t
)
sizeof
(
buf
)
==
...
@@ -3340,7 +3297,7 @@ void test_nghttp2_session_on_data_received_fail_fast(void) {
...
@@ -3340,7 +3297,7 @@ void test_nghttp2_session_on_data_received_fail_fast(void) {
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
NULL
);
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
NULL
);
/* DATA to closed stream with explicit closed (remote) */
/* DATA to closed stream with explicit closed (remote) */
stream
=
open_stream
(
session
,
1
);
stream
=
open_
recv_
stream
(
session
,
1
);
nghttp2_stream_shutdown
(
stream
,
NGHTTP2_SHUT_RD
);
nghttp2_stream_shutdown
(
stream
,
NGHTTP2_SHUT_RD
);
nghttp2_session_close_stream
(
session
,
1
,
NGHTTP2_NO_ERROR
);
nghttp2_session_close_stream
(
session
,
1
,
NGHTTP2_NO_ERROR
);
...
@@ -3402,9 +3359,8 @@ void test_nghttp2_session_send_headers_reply(void) {
...
@@ -3402,9 +3359,8 @@ void test_nghttp2_session_send_headers_reply(void) {
memset
(
&
callbacks
,
0
,
sizeof
(
nghttp2_session_callbacks
));
memset
(
&
callbacks
,
0
,
sizeof
(
nghttp2_session_callbacks
));
callbacks
.
send_callback
=
null_send_callback
;
callbacks
.
send_callback
=
null_send_callback
;
CU_ASSERT
(
0
==
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
NULL
));
CU_ASSERT
(
0
==
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
NULL
));
nghttp2_session_open_stream
(
session
,
2
,
NGHTTP2_STREAM_FLAG_NONE
,
open_recv_stream2
(
session
,
1
,
NGHTTP2_STREAM_OPENING
);
&
pri_spec_default
,
NGHTTP2_STREAM_OPENING
,
NULL
);
item
=
mem
->
malloc
(
sizeof
(
nghttp2_outbound_item
),
NULL
);
item
=
mem
->
malloc
(
sizeof
(
nghttp2_outbound_item
),
NULL
);
...
@@ -3412,11 +3368,11 @@ void test_nghttp2_session_send_headers_reply(void) {
...
@@ -3412,11 +3368,11 @@ void test_nghttp2_session_send_headers_reply(void) {
frame
=
&
item
->
frame
;
frame
=
&
item
->
frame
;
nghttp2_frame_headers_init
(
&
frame
->
headers
,
NGHTTP2_FLAG_END_HEADERS
,
2
,
nghttp2_frame_headers_init
(
&
frame
->
headers
,
NGHTTP2_FLAG_END_HEADERS
,
1
,
NGHTTP2_HCAT_HEADERS
,
NULL
,
NULL
,
0
);
NGHTTP2_HCAT_HEADERS
,
NULL
,
NULL
,
0
);
nghttp2_session_add_item
(
session
,
item
);
nghttp2_session_add_item
(
session
,
item
);
CU_ASSERT
(
0
==
nghttp2_session_send
(
session
));
CU_ASSERT
(
0
==
nghttp2_session_send
(
session
));
stream
=
nghttp2_session_get_stream
(
session
,
2
);
stream
=
nghttp2_session_get_stream
(
session
,
1
);
CU_ASSERT
(
NGHTTP2_STREAM_OPENED
==
stream
->
state
);
CU_ASSERT
(
NGHTTP2_STREAM_OPENED
==
stream
->
state
);
nghttp2_session_del
(
session
);
nghttp2_session_del
(
session
);
...
@@ -3498,8 +3454,7 @@ void test_nghttp2_session_send_headers_push_reply(void) {
...
@@ -3498,8 +3454,7 @@ void test_nghttp2_session_send_headers_push_reply(void) {
callbacks
.
send_callback
=
null_send_callback
;
callbacks
.
send_callback
=
null_send_callback
;
CU_ASSERT
(
0
==
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
NULL
));
CU_ASSERT
(
0
==
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
NULL
));
nghttp2_session_open_stream
(
session
,
2
,
NGHTTP2_STREAM_FLAG_NONE
,
open_sent_stream2
(
session
,
2
,
NGHTTP2_STREAM_RESERVED
);
&
pri_spec_default
,
NGHTTP2_STREAM_RESERVED
,
NULL
);
item
=
mem
->
malloc
(
sizeof
(
nghttp2_outbound_item
),
NULL
);
item
=
mem
->
malloc
(
sizeof
(
nghttp2_outbound_item
),
NULL
);
...
@@ -3532,8 +3487,7 @@ void test_nghttp2_session_send_rst_stream(void) {
...
@@ -3532,8 +3487,7 @@ void test_nghttp2_session_send_rst_stream(void) {
memset
(
&
callbacks
,
0
,
sizeof
(
nghttp2_session_callbacks
));
memset
(
&
callbacks
,
0
,
sizeof
(
nghttp2_session_callbacks
));
callbacks
.
send_callback
=
null_send_callback
;
callbacks
.
send_callback
=
null_send_callback
;
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
&
user_data
);
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
&
user_data
);
nghttp2_session_open_stream
(
session
,
1
,
NGHTTP2_STREAM_FLAG_NONE
,
open_sent_stream
(
session
,
1
);
&
pri_spec_default
,
NGHTTP2_STREAM_OPENING
,
NULL
);
item
=
mem
->
malloc
(
sizeof
(
nghttp2_outbound_item
),
NULL
);
item
=
mem
->
malloc
(
sizeof
(
nghttp2_outbound_item
),
NULL
);
...
@@ -3566,8 +3520,7 @@ void test_nghttp2_session_send_push_promise(void) {
...
@@ -3566,8 +3520,7 @@ void test_nghttp2_session_send_push_promise(void) {
callbacks
.
on_frame_not_send_callback
=
on_frame_not_send_callback
;
callbacks
.
on_frame_not_send_callback
=
on_frame_not_send_callback
;
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
&
ud
);
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
&
ud
);
nghttp2_session_open_stream
(
session
,
1
,
NGHTTP2_STREAM_FLAG_NONE
,
open_recv_stream
(
session
,
1
);
&
pri_spec_default
,
NGHTTP2_STREAM_OPENING
,
NULL
);
item
=
mem
->
malloc
(
sizeof
(
nghttp2_outbound_item
),
NULL
);
item
=
mem
->
malloc
(
sizeof
(
nghttp2_outbound_item
),
NULL
);
...
@@ -3618,8 +3571,7 @@ void test_nghttp2_session_send_push_promise(void) {
...
@@ -3618,8 +3571,7 @@ void test_nghttp2_session_send_push_promise(void) {
/* PUSH_PROMISE from client is error */
/* PUSH_PROMISE from client is error */
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
&
ud
);
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
&
ud
);
nghttp2_session_open_stream
(
session
,
1
,
NGHTTP2_STREAM_FLAG_NONE
,
open_sent_stream
(
session
,
1
);
&
pri_spec_default
,
NGHTTP2_STREAM_OPENING
,
NULL
);
item
=
mem
->
malloc
(
sizeof
(
nghttp2_outbound_item
),
NULL
);
item
=
mem
->
malloc
(
sizeof
(
nghttp2_outbound_item
),
NULL
);
nghttp2_outbound_item_init
(
item
);
nghttp2_outbound_item_init
(
item
);
...
@@ -3739,9 +3691,7 @@ void test_nghttp2_session_reprioritize_stream(void) {
...
@@ -3739,9 +3691,7 @@ void test_nghttp2_session_reprioritize_stream(void) {
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
&
ud
);
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
&
ud
);
stream
=
nghttp2_session_open_stream
(
session
,
1
,
NGHTTP2_STREAM_FLAG_NONE
,
stream
=
open_recv_stream
(
session
,
1
);
&
pri_spec_default
,
NGHTTP2_STREAM_OPENING
,
NULL
);
nghttp2_priority_spec_init
(
&
pri_spec
,
0
,
10
,
0
);
nghttp2_priority_spec_init
(
&
pri_spec
,
0
,
10
,
0
);
...
@@ -3763,7 +3713,7 @@ void test_nghttp2_session_reprioritize_stream(void) {
...
@@ -3763,7 +3713,7 @@ void test_nghttp2_session_reprioritize_stream(void) {
CU_ASSERT
(
NGHTTP2_DEFAULT_WEIGHT
==
dep_stream
->
weight
);
CU_ASSERT
(
NGHTTP2_DEFAULT_WEIGHT
==
dep_stream
->
weight
);
dep_stream
=
open_stream
(
session
,
3
);
dep_stream
=
open_
recv_
stream
(
session
,
3
);
/* Change weight */
/* Change weight */
pri_spec
.
weight
=
128
;
pri_spec
.
weight
=
128
;
...
@@ -3815,9 +3765,7 @@ void test_nghttp2_session_reprioritize_stream_with_idle_stream_dep(void) {
...
@@ -3815,9 +3765,7 @@ void test_nghttp2_session_reprioritize_stream_with_idle_stream_dep(void) {
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
NULL
);
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
NULL
);
stream
=
nghttp2_session_open_stream
(
session
,
1
,
NGHTTP2_STREAM_FLAG_NONE
,
stream
=
open_recv_stream
(
session
,
1
);
&
pri_spec_default
,
NGHTTP2_STREAM_OPENING
,
NULL
);
session
->
pending_local_max_concurrent_stream
=
1
;
session
->
pending_local_max_concurrent_stream
=
1
;
...
@@ -3857,8 +3805,8 @@ void test_nghttp2_submit_data(void) {
...
@@ -3857,8 +3805,8 @@ void test_nghttp2_submit_data(void) {
aob
=
&
session
->
aob
;
aob
=
&
session
->
aob
;
framebufs
=
&
aob
->
framebufs
;
framebufs
=
&
aob
->
framebufs
;
nghttp2_session_open_stream
(
session
,
1
,
NGHTTP2_STREAM_FLAG_NONE
,
open_sent_stream
(
session
,
1
);
&
pri_spec_default
,
NGHTTP2_STREAM_OPENING
,
NULL
);
CU_ASSERT
(
CU_ASSERT
(
0
==
nghttp2_submit_data
(
session
,
NGHTTP2_FLAG_END_STREAM
,
1
,
&
data_prd
));
0
==
nghttp2_submit_data
(
session
,
NGHTTP2_FLAG_END_STREAM
,
1
,
&
data_prd
));
...
@@ -3899,8 +3847,8 @@ void test_nghttp2_submit_data_read_length_too_large(void) {
...
@@ -3899,8 +3847,8 @@ void test_nghttp2_submit_data_read_length_too_large(void) {
aob
=
&
session
->
aob
;
aob
=
&
session
->
aob
;
framebufs
=
&
aob
->
framebufs
;
framebufs
=
&
aob
->
framebufs
;
nghttp2_session_open_stream
(
session
,
1
,
NGHTTP2_STREAM_FLAG_NONE
,
open_sent_stream
(
session
,
1
);
&
pri_spec_default
,
NGHTTP2_STREAM_OPENING
,
NULL
);
CU_ASSERT
(
CU_ASSERT
(
0
==
nghttp2_submit_data
(
session
,
NGHTTP2_FLAG_END_STREAM
,
1
,
&
data_prd
));
0
==
nghttp2_submit_data
(
session
,
NGHTTP2_FLAG_END_STREAM
,
1
,
&
data_prd
));
...
@@ -3926,8 +3874,8 @@ void test_nghttp2_submit_data_read_length_too_large(void) {
...
@@ -3926,8 +3874,8 @@ void test_nghttp2_submit_data_read_length_too_large(void) {
session
->
remote_settings
.
max_frame_size
=
NGHTTP2_MAX_FRAME_SIZE_MAX
;
session
->
remote_settings
.
max_frame_size
=
NGHTTP2_MAX_FRAME_SIZE_MAX
;
nghttp2_session_open_stream
(
session
,
1
,
NGHTTP2_STREAM_FLAG_NONE
,
open_sent_stream
(
session
,
1
);
&
pri_spec_default
,
NGHTTP2_STREAM_OPENING
,
NULL
);
CU_ASSERT
(
CU_ASSERT
(
0
==
nghttp2_submit_data
(
session
,
NGHTTP2_FLAG_END_STREAM
,
1
,
&
data_prd
));
0
==
nghttp2_submit_data
(
session
,
NGHTTP2_FLAG_END_STREAM
,
1
,
&
data_prd
));
...
@@ -3978,8 +3926,8 @@ void test_nghttp2_submit_data_read_length_smallest(void) {
...
@@ -3978,8 +3926,8 @@ void test_nghttp2_submit_data_read_length_smallest(void) {
aob
=
&
session
->
aob
;
aob
=
&
session
->
aob
;
framebufs
=
&
aob
->
framebufs
;
framebufs
=
&
aob
->
framebufs
;
nghttp2_session_open_stream
(
session
,
1
,
NGHTTP2_STREAM_FLAG_NONE
,
open_sent_stream
(
session
,
1
);
&
pri_spec_default
,
NGHTTP2_STREAM_OPENING
,
NULL
);
CU_ASSERT
(
CU_ASSERT
(
0
==
nghttp2_submit_data
(
session
,
NGHTTP2_FLAG_END_STREAM
,
1
,
&
data_prd
));
0
==
nghttp2_submit_data
(
session
,
NGHTTP2_FLAG_END_STREAM
,
1
,
&
data_prd
));
...
@@ -4045,11 +3993,9 @@ void test_nghttp2_submit_data_twice(void) {
...
@@ -4045,11 +3993,9 @@ void test_nghttp2_submit_data_twice(void) {
CU_ASSERT
(
0
==
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
&
ud
));
CU_ASSERT
(
0
==
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
&
ud
));
nghttp2_session_open_stream
(
session
,
1
,
NGHTTP2_STREAM_FLAG_NONE
,
open_sent_stream
(
session
,
1
);
&
pri_spec_default
,
NGHTTP2_STREAM_OPENING
,
NULL
);
CU_ASSERT
(
0
==
nghttp2_submit_data
(
session
,
NGHTTP2_FLAG_NONE
,
1
,
&
data_prd
));
CU_ASSERT
(
0
==
nghttp2_submit_data
(
session
,
NGHTTP2_FLAG_NONE
,
1
,
&
data_prd
));
CU_ASSERT
(
0
==
nghttp2_session_send
(
session
));
CU_ASSERT
(
0
==
nghttp2_session_send
(
session
));
/* We should have sent 2 DATA frame with 16 bytes payload each */
/* We should have sent 2 DATA frame with 16 bytes payload each */
...
@@ -4084,6 +4030,15 @@ void test_nghttp2_submit_request_with_data(void) {
...
@@ -4084,6 +4030,15 @@ void test_nghttp2_submit_request_with_data(void) {
CU_ASSERT
(
0
==
ud
.
data_source_length
);
CU_ASSERT
(
0
==
ud
.
data_source_length
);
nghttp2_session_del
(
session
);
nghttp2_session_del
(
session
);
/* nghttp2_submit_request() with server session is error */
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
NULL
);
CU_ASSERT
(
NGHTTP2_ERR_PROTO
==
nghttp2_submit_request
(
session
,
NULL
,
reqnv
,
ARRLEN
(
reqnv
),
NULL
,
NULL
));
nghttp2_session_del
(
session
);
}
}
void
test_nghttp2_submit_request_without_data
(
void
)
{
void
test_nghttp2_submit_request_without_data
(
void
)
{
...
@@ -4160,8 +4115,7 @@ void test_nghttp2_submit_response_with_data(void) {
...
@@ -4160,8 +4115,7 @@ void test_nghttp2_submit_response_with_data(void) {
data_prd
.
read_callback
=
fixed_length_data_source_read_callback
;
data_prd
.
read_callback
=
fixed_length_data_source_read_callback
;
ud
.
data_source_length
=
64
*
1024
-
1
;
ud
.
data_source_length
=
64
*
1024
-
1
;
CU_ASSERT
(
0
==
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
&
ud
));
CU_ASSERT
(
0
==
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
&
ud
));
nghttp2_session_open_stream
(
session
,
1
,
NGHTTP2_FLAG_END_STREAM
,
open_recv_stream2
(
session
,
1
,
NGHTTP2_STREAM_OPENING
);
&
pri_spec_default
,
NGHTTP2_STREAM_OPENING
,
NULL
);
CU_ASSERT
(
0
==
nghttp2_submit_response
(
session
,
1
,
resnv
,
ARRLEN
(
resnv
),
CU_ASSERT
(
0
==
nghttp2_submit_response
(
session
,
1
,
resnv
,
ARRLEN
(
resnv
),
&
data_prd
));
&
data_prd
));
item
=
nghttp2_session_get_next_ob_item
(
session
);
item
=
nghttp2_session_get_next_ob_item
(
session
);
...
@@ -4172,6 +4126,19 @@ void test_nghttp2_submit_response_with_data(void) {
...
@@ -4172,6 +4126,19 @@ void test_nghttp2_submit_response_with_data(void) {
CU_ASSERT
(
0
==
ud
.
data_source_length
);
CU_ASSERT
(
0
==
ud
.
data_source_length
);
nghttp2_session_del
(
session
);
nghttp2_session_del
(
session
);
/* Various error cases */
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
NULL
);
/* Calling nghttp2_submit_response() with client session is error */
CU_ASSERT
(
NGHTTP2_ERR_PROTO
==
nghttp2_submit_response
(
session
,
1
,
resnv
,
ARRLEN
(
resnv
),
NULL
));
/* Stream ID <= 0 is error */
CU_ASSERT
(
NGHTTP2_ERR_INVALID_ARGUMENT
==
nghttp2_submit_response
(
session
,
0
,
resnv
,
ARRLEN
(
resnv
),
NULL
));
nghttp2_session_del
(
session
);
}
}
void
test_nghttp2_submit_response_without_data
(
void
)
{
void
test_nghttp2_submit_response_without_data
(
void
)
{
...
@@ -4198,8 +4165,7 @@ void test_nghttp2_submit_response_without_data(void) {
...
@@ -4198,8 +4165,7 @@ void test_nghttp2_submit_response_without_data(void) {
CU_ASSERT
(
0
==
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
&
ud
));
CU_ASSERT
(
0
==
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
&
ud
));
nghttp2_hd_inflate_init
(
&
inflater
,
mem
);
nghttp2_hd_inflate_init
(
&
inflater
,
mem
);
nghttp2_session_open_stream
(
session
,
1
,
NGHTTP2_FLAG_END_STREAM
,
open_recv_stream2
(
session
,
1
,
NGHTTP2_STREAM_OPENING
);
&
pri_spec_default
,
NGHTTP2_STREAM_OPENING
,
NULL
);
CU_ASSERT
(
0
==
nghttp2_submit_response
(
session
,
1
,
resnv
,
ARRLEN
(
resnv
),
CU_ASSERT
(
0
==
nghttp2_submit_response
(
session
,
1
,
resnv
,
ARRLEN
(
resnv
),
&
data_prd
));
&
data_prd
));
item
=
nghttp2_session_get_next_ob_item
(
session
);
item
=
nghttp2_session_get_next_ob_item
(
session
);
...
@@ -4235,8 +4201,7 @@ void test_nghttp2_submit_response_push_response(void) {
...
@@ -4235,8 +4201,7 @@ void test_nghttp2_submit_response_push_response(void) {
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
&
ud
);
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
&
ud
);
nghttp2_session_open_stream
(
session
,
2
,
NGHTTP2_FLAG_NONE
,
&
pri_spec_default
,
open_sent_stream2
(
session
,
2
,
NGHTTP2_STREAM_RESERVED
);
NGHTTP2_STREAM_RESERVED
,
NULL
);
session
->
goaway_flags
|=
NGHTTP2_GOAWAY_RECV
;
session
->
goaway_flags
|=
NGHTTP2_GOAWAY_RECV
;
...
@@ -4276,8 +4241,7 @@ void test_nghttp2_submit_trailer(void) {
...
@@ -4276,8 +4241,7 @@ void test_nghttp2_submit_trailer(void) {
CU_ASSERT
(
0
==
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
&
ud
));
CU_ASSERT
(
0
==
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
&
ud
));
nghttp2_hd_inflate_init
(
&
inflater
,
mem
);
nghttp2_hd_inflate_init
(
&
inflater
,
mem
);
nghttp2_session_open_stream
(
session
,
1
,
NGHTTP2_FLAG_END_STREAM
,
open_recv_stream2
(
session
,
1
,
NGHTTP2_STREAM_OPENING
);
&
pri_spec_default
,
NGHTTP2_STREAM_OPENING
,
NULL
);
CU_ASSERT
(
0
==
nghttp2_submit_response
(
session
,
1
,
resnv
,
ARRLEN
(
resnv
),
CU_ASSERT
(
0
==
nghttp2_submit_response
(
session
,
1
,
resnv
,
ARRLEN
(
resnv
),
&
data_prd
));
&
data_prd
));
CU_ASSERT
(
0
==
nghttp2_session_send
(
session
));
CU_ASSERT
(
0
==
nghttp2_session_send
(
session
));
...
@@ -4306,6 +4270,18 @@ void test_nghttp2_submit_trailer(void) {
...
@@ -4306,6 +4270,18 @@ void test_nghttp2_submit_trailer(void) {
nghttp2_frame_headers_free
(
&
frame
.
headers
,
mem
);
nghttp2_frame_headers_free
(
&
frame
.
headers
,
mem
);
nghttp2_hd_inflate_free
(
&
inflater
);
nghttp2_hd_inflate_free
(
&
inflater
);
nghttp2_session_del
(
session
);
nghttp2_session_del
(
session
);
/* Specifying stream ID <= 0 is error */
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
NULL
);
open_recv_stream
(
session
,
1
);
CU_ASSERT
(
NGHTTP2_ERR_INVALID_ARGUMENT
==
nghttp2_submit_trailer
(
session
,
0
,
trailernv
,
ARRLEN
(
trailernv
)));
CU_ASSERT
(
NGHTTP2_ERR_INVALID_ARGUMENT
==
nghttp2_submit_trailer
(
session
,
-
1
,
trailernv
,
ARRLEN
(
trailernv
)));
nghttp2_session_del
(
session
);
}
}
void
test_nghttp2_submit_headers_start_stream
(
void
)
{
void
test_nghttp2_submit_headers_start_stream
(
void
)
{
...
@@ -4362,9 +4338,7 @@ void test_nghttp2_submit_headers_reply(void) {
...
@@ -4362,9 +4338,7 @@ void test_nghttp2_submit_headers_reply(void) {
CU_ASSERT
(
0
==
nghttp2_session_send
(
session
));
CU_ASSERT
(
0
==
nghttp2_session_send
(
session
));
CU_ASSERT
(
0
==
ud
.
frame_send_cb_called
);
CU_ASSERT
(
0
==
ud
.
frame_send_cb_called
);
stream
=
nghttp2_session_open_stream
(
session
,
1
,
NGHTTP2_STREAM_FLAG_NONE
,
stream
=
open_recv_stream2
(
session
,
1
,
NGHTTP2_STREAM_OPENING
);
&
pri_spec_default
,
NGHTTP2_STREAM_OPENING
,
NULL
);
CU_ASSERT
(
0
==
nghttp2_submit_headers
(
session
,
NGHTTP2_FLAG_END_STREAM
,
1
,
CU_ASSERT
(
0
==
nghttp2_submit_headers
(
session
,
NGHTTP2_FLAG_END_STREAM
,
1
,
NULL
,
resnv
,
ARRLEN
(
resnv
),
NULL
));
NULL
,
resnv
,
ARRLEN
(
resnv
),
NULL
));
...
@@ -4388,9 +4362,7 @@ void test_nghttp2_submit_headers_push_reply(void) {
...
@@ -4388,9 +4362,7 @@ void test_nghttp2_submit_headers_push_reply(void) {
callbacks
.
on_frame_send_callback
=
on_frame_send_callback
;
callbacks
.
on_frame_send_callback
=
on_frame_send_callback
;
CU_ASSERT
(
0
==
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
&
ud
));
CU_ASSERT
(
0
==
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
&
ud
));
stream
=
nghttp2_session_open_stream
(
session
,
2
,
NGHTTP2_STREAM_FLAG_NONE
,
stream
=
open_sent_stream2
(
session
,
2
,
NGHTTP2_STREAM_RESERVED
);
&
pri_spec_default
,
NGHTTP2_STREAM_RESERVED
,
NULL
);
CU_ASSERT
(
0
==
nghttp2_submit_headers
(
session
,
NGHTTP2_FLAG_NONE
,
2
,
NULL
,
CU_ASSERT
(
0
==
nghttp2_submit_headers
(
session
,
NGHTTP2_FLAG_NONE
,
2
,
NULL
,
resnv
,
ARRLEN
(
resnv
),
&
foo
));
resnv
,
ARRLEN
(
resnv
),
&
foo
));
...
@@ -4407,8 +4379,7 @@ void test_nghttp2_submit_headers_push_reply(void) {
...
@@ -4407,8 +4379,7 @@ void test_nghttp2_submit_headers_push_reply(void) {
/* Sending HEADERS from client against stream in reserved state is
/* Sending HEADERS from client against stream in reserved state is
error */
error */
CU_ASSERT
(
0
==
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
&
ud
));
CU_ASSERT
(
0
==
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
&
ud
));
nghttp2_session_open_stream
(
session
,
2
,
NGHTTP2_STREAM_FLAG_NONE
,
open_recv_stream2
(
session
,
2
,
NGHTTP2_STREAM_RESERVED
);
&
pri_spec_default
,
NGHTTP2_STREAM_RESERVED
,
NULL
);
CU_ASSERT
(
0
==
nghttp2_submit_headers
(
session
,
NGHTTP2_FLAG_NONE
,
2
,
NULL
,
CU_ASSERT
(
0
==
nghttp2_submit_headers
(
session
,
NGHTTP2_FLAG_NONE
,
2
,
NULL
,
reqnv
,
ARRLEN
(
reqnv
),
NULL
));
reqnv
,
ARRLEN
(
reqnv
),
NULL
));
...
@@ -4463,9 +4434,7 @@ void test_nghttp2_submit_headers(void) {
...
@@ -4463,9 +4434,7 @@ void test_nghttp2_submit_headers(void) {
CU_ASSERT
(
0
==
nghttp2_session_send
(
session
));
CU_ASSERT
(
0
==
nghttp2_session_send
(
session
));
CU_ASSERT
(
0
==
ud
.
frame_send_cb_called
);
CU_ASSERT
(
0
==
ud
.
frame_send_cb_called
);
stream
=
nghttp2_session_open_stream
(
session
,
1
,
NGHTTP2_STREAM_FLAG_NONE
,
stream
=
open_sent_stream
(
session
,
1
);
&
pri_spec_default
,
NGHTTP2_STREAM_OPENING
,
NULL
);
CU_ASSERT
(
0
==
nghttp2_submit_headers
(
session
,
NGHTTP2_FLAG_END_STREAM
,
1
,
CU_ASSERT
(
0
==
nghttp2_submit_headers
(
session
,
NGHTTP2_FLAG_END_STREAM
,
1
,
NULL
,
reqnv
,
ARRLEN
(
reqnv
),
NULL
));
NULL
,
reqnv
,
ARRLEN
(
reqnv
),
NULL
));
...
@@ -4503,6 +4472,22 @@ void test_nghttp2_submit_headers(void) {
...
@@ -4503,6 +4472,22 @@ void test_nghttp2_submit_headers(void) {
reqnv
,
ARRLEN
(
reqnv
),
NULL
));
reqnv
,
ARRLEN
(
reqnv
),
NULL
));
nghttp2_session_del
(
session
);
nghttp2_session_del
(
session
);
/* Error cases with invalid stream ID */
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
NULL
);
/* Sending nghttp2_submit_headers() with stream_id == 1 and server
session is error */
CU_ASSERT
(
NGHTTP2_ERR_PROTO
==
nghttp2_submit_headers
(
session
,
NGHTTP2_FLAG_NONE
,
-
1
,
NULL
,
reqnv
,
ARRLEN
(
reqnv
),
NULL
));
/* Sending stream ID <= 0 is error */
CU_ASSERT
(
NGHTTP2_ERR_INVALID_ARGUMENT
==
nghttp2_submit_headers
(
session
,
NGHTTP2_FLAG_NONE
,
0
,
NULL
,
resnv
,
ARRLEN
(
resnv
),
NULL
));
nghttp2_session_del
(
session
);
}
}
void
test_nghttp2_submit_headers_continuation
(
void
)
{
void
test_nghttp2_submit_headers_continuation
(
void
)
{
...
@@ -4556,9 +4541,7 @@ void test_nghttp2_submit_priority(void) {
...
@@ -4556,9 +4541,7 @@ void test_nghttp2_submit_priority(void) {
callbacks
.
on_frame_send_callback
=
on_frame_send_callback
;
callbacks
.
on_frame_send_callback
=
on_frame_send_callback
;
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
&
ud
);
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
&
ud
);
stream
=
nghttp2_session_open_stream
(
session
,
1
,
NGHTTP2_STREAM_FLAG_NONE
,
stream
=
open_sent_stream
(
session
,
1
);
&
pri_spec_default
,
NGHTTP2_STREAM_OPENING
,
NULL
);
nghttp2_priority_spec_init
(
&
pri_spec
,
0
,
3
,
0
);
nghttp2_priority_spec_init
(
&
pri_spec
,
0
,
3
,
0
);
...
@@ -4687,14 +4670,11 @@ void test_nghttp2_submit_settings_update_local_window_size(void) {
...
@@ -4687,14 +4670,11 @@ void test_nghttp2_submit_settings_update_local_window_size(void) {
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
NULL
);
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
NULL
);
stream
=
nghttp2_session_open_stream
(
session
,
1
,
NGHTTP2_STREAM_FLAG_NONE
,
stream
=
open_recv_stream
(
session
,
1
);
&
pri_spec_default
,
NGHTTP2_STREAM_OPENED
,
NULL
);
stream
->
local_window_size
=
NGHTTP2_INITIAL_WINDOW_SIZE
+
100
;
stream
->
local_window_size
=
NGHTTP2_INITIAL_WINDOW_SIZE
+
100
;
stream
->
recv_window_size
=
32768
;
stream
->
recv_window_size
=
32768
;
nghttp2_session_open_stream
(
session
,
3
,
NGHTTP2_STREAM_FLAG_NONE
,
open_recv_stream
(
session
,
3
);
&
pri_spec_default
,
NGHTTP2_STREAM_OPENED
,
NULL
);
CU_ASSERT
(
0
==
nghttp2_submit_settings
(
session
,
NGHTTP2_FLAG_NONE
,
iv
,
1
));
CU_ASSERT
(
0
==
nghttp2_submit_settings
(
session
,
NGHTTP2_FLAG_NONE
,
iv
,
1
));
CU_ASSERT
(
0
==
nghttp2_session_send
(
session
));
CU_ASSERT
(
0
==
nghttp2_session_send
(
session
));
...
@@ -4716,9 +4696,7 @@ void test_nghttp2_submit_settings_update_local_window_size(void) {
...
@@ -4716,9 +4696,7 @@ void test_nghttp2_submit_settings_update_local_window_size(void) {
/* Check overflow case */
/* Check overflow case */
iv
[
0
].
value
=
128
*
1024
;
iv
[
0
].
value
=
128
*
1024
;
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
NULL
);
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
NULL
);
stream
=
nghttp2_session_open_stream
(
session
,
1
,
NGHTTP2_STREAM_FLAG_NONE
,
stream
=
open_recv_stream
(
session
,
1
);
&
pri_spec_default
,
NGHTTP2_STREAM_OPENED
,
NULL
);
stream
->
local_window_size
=
NGHTTP2_MAX_WINDOW_SIZE
;
stream
->
local_window_size
=
NGHTTP2_MAX_WINDOW_SIZE
;
CU_ASSERT
(
0
==
nghttp2_submit_settings
(
session
,
NGHTTP2_FLAG_NONE
,
iv
,
1
));
CU_ASSERT
(
0
==
nghttp2_submit_settings
(
session
,
NGHTTP2_FLAG_NONE
,
iv
,
1
));
...
@@ -4822,8 +4800,7 @@ void test_nghttp2_submit_push_promise(void) {
...
@@ -4822,8 +4800,7 @@ void test_nghttp2_submit_push_promise(void) {
callbacks
.
on_frame_not_send_callback
=
on_frame_not_send_callback
;
callbacks
.
on_frame_not_send_callback
=
on_frame_not_send_callback
;
CU_ASSERT
(
0
==
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
&
ud
));
CU_ASSERT
(
0
==
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
&
ud
));
nghttp2_session_open_stream
(
session
,
1
,
NGHTTP2_STREAM_FLAG_NONE
,
open_recv_stream
(
session
,
1
);
&
pri_spec_default
,
NGHTTP2_STREAM_OPENING
,
NULL
);
CU_ASSERT
(
2
==
nghttp2_submit_push_promise
(
session
,
NGHTTP2_FLAG_NONE
,
1
,
CU_ASSERT
(
2
==
nghttp2_submit_push_promise
(
session
,
NGHTTP2_FLAG_NONE
,
1
,
reqnv
,
ARRLEN
(
reqnv
),
&
ud
));
reqnv
,
ARRLEN
(
reqnv
),
&
ud
));
...
@@ -4848,7 +4825,12 @@ void test_nghttp2_submit_push_promise(void) {
...
@@ -4848,7 +4825,12 @@ void test_nghttp2_submit_push_promise(void) {
/* submit PUSH_PROMISE while associated stream is not opened */
/* submit PUSH_PROMISE while associated stream is not opened */
CU_ASSERT
(
NGHTTP2_ERR_STREAM_CLOSED
==
CU_ASSERT
(
NGHTTP2_ERR_STREAM_CLOSED
==
nghttp2_submit_push_promise
(
session
,
NGHTTP2_FLAG_NONE
,
3
,
reqnv
,
nghttp2_submit_push_promise
(
session
,
NGHTTP2_FLAG_NONE
,
3
,
reqnv
,
ARRLEN
(
reqnv
),
&
ud
));
ARRLEN
(
reqnv
),
NULL
));
/* Stream ID <= 0 is error */
CU_ASSERT
(
NGHTTP2_ERR_INVALID_ARGUMENT
==
nghttp2_submit_push_promise
(
session
,
NGHTTP2_FLAG_NONE
,
0
,
reqnv
,
ARRLEN
(
reqnv
),
NULL
));
nghttp2_session_del
(
session
);
nghttp2_session_del
(
session
);
}
}
...
@@ -4864,9 +4846,7 @@ void test_nghttp2_submit_window_update(void) {
...
@@ -4864,9 +4846,7 @@ void test_nghttp2_submit_window_update(void) {
callbacks
.
send_callback
=
null_send_callback
;
callbacks
.
send_callback
=
null_send_callback
;
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
&
ud
);
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
&
ud
);
stream
=
nghttp2_session_open_stream
(
session
,
2
,
NGHTTP2_STREAM_FLAG_NONE
,
stream
=
open_recv_stream
(
session
,
2
);
&
pri_spec_default
,
NGHTTP2_STREAM_OPENED
,
NULL
);
stream
->
recv_window_size
=
4096
;
stream
->
recv_window_size
=
4096
;
CU_ASSERT
(
0
==
CU_ASSERT
(
0
==
...
@@ -4913,9 +4893,7 @@ void test_nghttp2_submit_window_update_local_window_size(void) {
...
@@ -4913,9 +4893,7 @@ void test_nghttp2_submit_window_update_local_window_size(void) {
callbacks
.
send_callback
=
null_send_callback
;
callbacks
.
send_callback
=
null_send_callback
;
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
NULL
);
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
NULL
);
stream
=
nghttp2_session_open_stream
(
session
,
2
,
NGHTTP2_STREAM_FLAG_NONE
,
stream
=
open_recv_stream
(
session
,
2
);
&
pri_spec_default
,
NGHTTP2_STREAM_OPENED
,
NULL
);
stream
->
recv_window_size
=
4096
;
stream
->
recv_window_size
=
4096
;
CU_ASSERT
(
0
==
nghttp2_submit_window_update
(
session
,
NGHTTP2_FLAG_NONE
,
2
,
CU_ASSERT
(
0
==
nghttp2_submit_window_update
(
session
,
NGHTTP2_FLAG_NONE
,
2
,
...
@@ -5060,27 +5038,31 @@ void test_nghttp2_submit_invalid_nv(void) {
...
@@ -5060,27 +5038,31 @@ void test_nghttp2_submit_invalid_nv(void) {
CU_ASSERT
(
0
==
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
NULL
));
CU_ASSERT
(
0
==
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
NULL
));
/* nghttp2_submit_request */
CU_ASSERT
(
0
<
nghttp2_submit_request
(
session
,
NULL
,
empty_name_nv
,
ARRLEN
(
empty_name_nv
),
NULL
,
NULL
));
/* nghttp2_submit_response */
/* nghttp2_submit_response */
CU_ASSERT
(
0
==
nghttp2_submit_response
(
session
,
2
,
empty_name_nv
,
CU_ASSERT
(
0
==
nghttp2_submit_response
(
session
,
2
,
empty_name_nv
,
ARRLEN
(
empty_name_nv
),
NULL
));
ARRLEN
(
empty_name_nv
),
NULL
));
/* nghttp2_submit_headers */
CU_ASSERT
(
0
<
nghttp2_submit_headers
(
session
,
NGHTTP2_FLAG_NONE
,
-
1
,
NULL
,
empty_name_nv
,
ARRLEN
(
empty_name_nv
),
NULL
));
/* nghttp2_submit_push_promise */
/* nghttp2_submit_push_promise */
open_stream
(
session
,
1
);
open_
recv_
stream
(
session
,
1
);
CU_ASSERT
(
0
<
nghttp2_submit_push_promise
(
session
,
NGHTTP2_FLAG_NONE
,
1
,
CU_ASSERT
(
0
<
nghttp2_submit_push_promise
(
session
,
NGHTTP2_FLAG_NONE
,
1
,
empty_name_nv
,
empty_name_nv
,
ARRLEN
(
empty_name_nv
),
NULL
));
ARRLEN
(
empty_name_nv
),
NULL
));
nghttp2_session_del
(
session
);
nghttp2_session_del
(
session
);
CU_ASSERT
(
0
==
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
NULL
));
/* nghttp2_submit_request */
CU_ASSERT
(
0
<
nghttp2_submit_request
(
session
,
NULL
,
empty_name_nv
,
ARRLEN
(
empty_name_nv
),
NULL
,
NULL
));
/* nghttp2_submit_headers */
CU_ASSERT
(
0
<
nghttp2_submit_headers
(
session
,
NGHTTP2_FLAG_NONE
,
-
1
,
NULL
,
empty_name_nv
,
ARRLEN
(
empty_name_nv
),
NULL
));
nghttp2_session_del
(
session
);
}
}
void
test_nghttp2_submit_extension
(
void
)
{
void
test_nghttp2_submit_extension
(
void
)
{
...
@@ -5211,6 +5193,7 @@ void test_nghttp2_session_open_stream(void) {
...
@@ -5211,6 +5193,7 @@ void test_nghttp2_session_open_stream(void) {
NGHTTP2_STREAM_OPENED
,
NULL
);
NGHTTP2_STREAM_OPENED
,
NULL
);
CU_ASSERT
(
NGHTTP2_DEFAULT_WEIGHT
==
stream
->
weight
);
CU_ASSERT
(
NGHTTP2_DEFAULT_WEIGHT
==
stream
->
weight
);
CU_ASSERT
(
&
session
->
root
==
stream
->
dep_prev
);
nghttp2_session_del
(
session
);
nghttp2_session_del
(
session
);
...
@@ -5275,7 +5258,7 @@ void test_nghttp2_session_get_next_ob_item(void) {
...
@@ -5275,7 +5258,7 @@ void test_nghttp2_session_get_next_ob_item(void) {
memset
(
&
callbacks
,
0
,
sizeof
(
nghttp2_session_callbacks
));
memset
(
&
callbacks
,
0
,
sizeof
(
nghttp2_session_callbacks
));
callbacks
.
send_callback
=
null_send_callback
;
callbacks
.
send_callback
=
null_send_callback
;
nghttp2_session_
server
_new
(
&
session
,
&
callbacks
,
NULL
);
nghttp2_session_
client
_new
(
&
session
,
&
callbacks
,
NULL
);
session
->
remote_settings
.
max_concurrent_streams
=
2
;
session
->
remote_settings
.
max_concurrent_streams
=
2
;
CU_ASSERT
(
NULL
==
nghttp2_session_get_next_ob_item
(
session
));
CU_ASSERT
(
NULL
==
nghttp2_session_get_next_ob_item
(
session
));
...
@@ -5283,7 +5266,7 @@ void test_nghttp2_session_get_next_ob_item(void) {
...
@@ -5283,7 +5266,7 @@ void test_nghttp2_session_get_next_ob_item(void) {
CU_ASSERT
(
NGHTTP2_PING
==
CU_ASSERT
(
NGHTTP2_PING
==
nghttp2_session_get_next_ob_item
(
session
)
->
frame
.
hd
.
type
);
nghttp2_session_get_next_ob_item
(
session
)
->
frame
.
hd
.
type
);
nghttp2_submit_request
(
session
,
NULL
,
NULL
,
0
,
NULL
,
NULL
);
CU_ASSERT
(
1
==
nghttp2_submit_request
(
session
,
NULL
,
NULL
,
0
,
NULL
,
NULL
)
);
CU_ASSERT
(
NGHTTP2_PING
==
CU_ASSERT
(
NGHTTP2_PING
==
nghttp2_session_get_next_ob_item
(
session
)
->
frame
.
hd
.
type
);
nghttp2_session_get_next_ob_item
(
session
)
->
frame
.
hd
.
type
);
...
@@ -5292,17 +5275,18 @@ void test_nghttp2_session_get_next_ob_item(void) {
...
@@ -5292,17 +5275,18 @@ void test_nghttp2_session_get_next_ob_item(void) {
/* Incoming stream does not affect the number of outgoing max
/* Incoming stream does not affect the number of outgoing max
concurrent streams. */
concurrent streams. */
nghttp2_session_open_stream
(
session
,
1
,
NGHTTP2_STREAM_FLAG_NONE
,
open_recv_stream
(
session
,
2
);
&
pri_spec_default
,
NGHTTP2_STREAM_OPENING
,
NULL
);
nghttp2_priority_spec_init
(
&
pri_spec
,
0
,
NGHTTP2_MAX_WEIGHT
,
0
);
nghttp2_priority_spec_init
(
&
pri_spec
,
0
,
NGHTTP2_MAX_WEIGHT
,
0
);
nghttp2_submit_request
(
session
,
&
pri_spec
,
NULL
,
0
,
NULL
,
NULL
);
CU_ASSERT
(
3
==
nghttp2_submit_request
(
session
,
&
pri_spec
,
NULL
,
0
,
NULL
,
NULL
));
CU_ASSERT
(
NGHTTP2_HEADERS
==
CU_ASSERT
(
NGHTTP2_HEADERS
==
nghttp2_session_get_next_ob_item
(
session
)
->
frame
.
hd
.
type
);
nghttp2_session_get_next_ob_item
(
session
)
->
frame
.
hd
.
type
);
CU_ASSERT
(
0
==
nghttp2_session_send
(
session
));
CU_ASSERT
(
0
==
nghttp2_session_send
(
session
));
nghttp2_submit_request
(
session
,
&
pri_spec
,
NULL
,
0
,
NULL
,
NULL
);
CU_ASSERT
(
5
==
nghttp2_submit_request
(
session
,
&
pri_spec
,
NULL
,
0
,
NULL
,
NULL
));
CU_ASSERT
(
NULL
==
nghttp2_session_get_next_ob_item
(
session
));
CU_ASSERT
(
NULL
==
nghttp2_session_get_next_ob_item
(
session
));
session
->
remote_settings
.
max_concurrent_streams
=
3
;
session
->
remote_settings
.
max_concurrent_streams
=
3
;
...
@@ -5311,6 +5295,16 @@ void test_nghttp2_session_get_next_ob_item(void) {
...
@@ -5311,6 +5295,16 @@ void test_nghttp2_session_get_next_ob_item(void) {
nghttp2_session_get_next_ob_item
(
session
)
->
frame
.
hd
.
type
);
nghttp2_session_get_next_ob_item
(
session
)
->
frame
.
hd
.
type
);
nghttp2_session_del
(
session
);
nghttp2_session_del
(
session
);
/* Check that push reply HEADERS are queued into ob_ss_pq */
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
NULL
);
session
->
remote_settings
.
max_concurrent_streams
=
0
;
open_sent_stream2
(
session
,
2
,
NGHTTP2_STREAM_RESERVED
);
CU_ASSERT
(
0
==
nghttp2_submit_headers
(
session
,
NGHTTP2_FLAG_END_STREAM
,
2
,
NULL
,
NULL
,
0
,
NULL
));
CU_ASSERT
(
NULL
==
nghttp2_session_get_next_ob_item
(
session
));
CU_ASSERT
(
1
==
nghttp2_outbound_queue_size
(
&
session
->
ob_syn
));
nghttp2_session_del
(
session
);
}
}
void
test_nghttp2_session_pop_next_ob_item
(
void
)
{
void
test_nghttp2_session_pop_next_ob_item
(
void
)
{
...
@@ -5318,14 +5312,13 @@ void test_nghttp2_session_pop_next_ob_item(void) {
...
@@ -5318,14 +5312,13 @@ void test_nghttp2_session_pop_next_ob_item(void) {
nghttp2_session_callbacks
callbacks
;
nghttp2_session_callbacks
callbacks
;
nghttp2_outbound_item
*
item
;
nghttp2_outbound_item
*
item
;
nghttp2_priority_spec
pri_spec
;
nghttp2_priority_spec
pri_spec
;
nghttp2_stream
*
stream
;
nghttp2_mem
*
mem
;
nghttp2_mem
*
mem
;
mem
=
nghttp2_mem_default
();
mem
=
nghttp2_mem_default
();
memset
(
&
callbacks
,
0
,
sizeof
(
nghttp2_session_callbacks
));
memset
(
&
callbacks
,
0
,
sizeof
(
nghttp2_session_callbacks
));
callbacks
.
send_callback
=
null_send_callback
;
callbacks
.
send_callback
=
null_send_callback
;
nghttp2_session_
server
_new
(
&
session
,
&
callbacks
,
NULL
);
nghttp2_session_
client
_new
(
&
session
,
&
callbacks
,
NULL
);
session
->
remote_settings
.
max_concurrent_streams
=
1
;
session
->
remote_settings
.
max_concurrent_streams
=
1
;
CU_ASSERT
(
NULL
==
nghttp2_session_pop_next_ob_item
(
session
));
CU_ASSERT
(
NULL
==
nghttp2_session_pop_next_ob_item
(
session
));
...
@@ -5350,27 +5343,13 @@ void test_nghttp2_session_pop_next_ob_item(void) {
...
@@ -5350,27 +5343,13 @@ void test_nghttp2_session_pop_next_ob_item(void) {
/* Incoming stream does not affect the number of outgoing max
/* Incoming stream does not affect the number of outgoing max
concurrent streams. */
concurrent streams. */
nghttp2_session_open_stream
(
session
,
1
,
NGHTTP2_STREAM_FLAG_NONE
,
open_recv_stream
(
session
,
4
);
&
pri_spec_default
,
NGHTTP2_STREAM_OPENING
,
NULL
);
/* In-flight outgoing stream */
/* In-flight outgoing stream */
nghttp2_session_open_stream
(
session
,
4
,
NGHTTP2_STREAM_FLAG_NONE
,
open_sent_stream
(
session
,
1
);
&
pri_spec_default
,
NGHTTP2_STREAM_OPENING
,
NULL
);
nghttp2_priority_spec_init
(
&
pri_spec
,
0
,
NGHTTP2_MAX_WEIGHT
,
0
);
nghttp2_priority_spec_init
(
&
pri_spec
,
0
,
NGHTTP2_MAX_WEIGHT
,
0
);
nghttp2_submit_request
(
session
,
&
pri_spec
,
NULL
,
0
,
NULL
,
NULL
);
nghttp2_submit_request
(
session
,
&
pri_spec
,
NULL
,
0
,
NULL
,
NULL
);
nghttp2_submit_response
(
session
,
1
,
NULL
,
0
,
NULL
);
item
=
nghttp2_session_pop_next_ob_item
(
session
);
CU_ASSERT
(
NGHTTP2_HEADERS
==
item
->
frame
.
hd
.
type
);
CU_ASSERT
(
1
==
item
->
frame
.
hd
.
stream_id
);
stream
=
nghttp2_session_get_stream
(
session
,
1
);
nghttp2_stream_detach_item
(
stream
);
nghttp2_outbound_item_free
(
item
,
mem
);
mem
->
free
(
item
,
NULL
);
CU_ASSERT
(
NULL
==
nghttp2_session_pop_next_ob_item
(
session
));
CU_ASSERT
(
NULL
==
nghttp2_session_pop_next_ob_item
(
session
));
...
@@ -5386,8 +5365,7 @@ void test_nghttp2_session_pop_next_ob_item(void) {
...
@@ -5386,8 +5365,7 @@ void test_nghttp2_session_pop_next_ob_item(void) {
/* Check that push reply HEADERS are queued into ob_ss_pq */
/* Check that push reply HEADERS are queued into ob_ss_pq */
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
NULL
);
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
NULL
);
session
->
remote_settings
.
max_concurrent_streams
=
0
;
session
->
remote_settings
.
max_concurrent_streams
=
0
;
nghttp2_session_open_stream
(
session
,
2
,
NGHTTP2_STREAM_FLAG_NONE
,
open_sent_stream2
(
session
,
2
,
NGHTTP2_STREAM_RESERVED
);
&
pri_spec_default
,
NGHTTP2_STREAM_RESERVED
,
NULL
);
CU_ASSERT
(
0
==
nghttp2_submit_headers
(
session
,
NGHTTP2_FLAG_END_STREAM
,
2
,
CU_ASSERT
(
0
==
nghttp2_submit_headers
(
session
,
NGHTTP2_FLAG_END_STREAM
,
2
,
NULL
,
NULL
,
0
,
NULL
));
NULL
,
NULL
,
0
,
NULL
));
CU_ASSERT
(
NULL
==
nghttp2_session_pop_next_ob_item
(
session
));
CU_ASSERT
(
NULL
==
nghttp2_session_pop_next_ob_item
(
session
));
...
@@ -5407,8 +5385,7 @@ void test_nghttp2_session_reply_fail(void) {
...
@@ -5407,8 +5385,7 @@ void test_nghttp2_session_reply_fail(void) {
data_prd
.
read_callback
=
fixed_length_data_source_read_callback
;
data_prd
.
read_callback
=
fixed_length_data_source_read_callback
;
ud
.
data_source_length
=
4
*
1024
;
ud
.
data_source_length
=
4
*
1024
;
CU_ASSERT
(
0
==
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
&
ud
));
CU_ASSERT
(
0
==
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
&
ud
));
nghttp2_session_open_stream
(
session
,
1
,
NGHTTP2_STREAM_FLAG_NONE
,
open_recv_stream2
(
session
,
1
,
NGHTTP2_STREAM_OPENING
);
&
pri_spec_default
,
NGHTTP2_STREAM_OPENING
,
NULL
);
CU_ASSERT
(
0
==
nghttp2_submit_response
(
session
,
1
,
NULL
,
0
,
&
data_prd
));
CU_ASSERT
(
0
==
nghttp2_submit_response
(
session
,
1
,
NULL
,
0
,
&
data_prd
));
CU_ASSERT
(
NGHTTP2_ERR_CALLBACK_FAILURE
==
nghttp2_session_send
(
session
));
CU_ASSERT
(
NGHTTP2_ERR_CALLBACK_FAILURE
==
nghttp2_session_send
(
session
));
nghttp2_session_del
(
session
);
nghttp2_session_del
(
session
);
...
@@ -5426,8 +5403,7 @@ void test_nghttp2_session_max_concurrent_streams(void) {
...
@@ -5426,8 +5403,7 @@ void test_nghttp2_session_max_concurrent_streams(void) {
callbacks
.
send_callback
=
null_send_callback
;
callbacks
.
send_callback
=
null_send_callback
;
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
NULL
);
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
NULL
);
nghttp2_session_open_stream
(
session
,
1
,
NGHTTP2_STREAM_FLAG_NONE
,
open_recv_stream
(
session
,
1
);
&
pri_spec_default
,
NGHTTP2_STREAM_OPENED
,
NULL
);
/* Check un-ACKed SETTINGS_MAX_CONCURRENT_STREAMS */
/* Check un-ACKed SETTINGS_MAX_CONCURRENT_STREAMS */
nghttp2_frame_headers_init
(
&
frame
.
headers
,
NGHTTP2_FLAG_END_HEADERS
,
3
,
nghttp2_frame_headers_init
(
&
frame
.
headers
,
NGHTTP2_FLAG_END_HEADERS
,
3
,
...
@@ -5474,8 +5450,7 @@ void test_nghttp2_session_stop_data_with_rst_stream(void) {
...
@@ -5474,8 +5450,7 @@ void test_nghttp2_session_stop_data_with_rst_stream(void) {
ud
.
data_source_length
=
NGHTTP2_DATA_PAYLOADLEN
*
4
;
ud
.
data_source_length
=
NGHTTP2_DATA_PAYLOADLEN
*
4
;
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
&
ud
);
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
&
ud
);
nghttp2_session_open_stream
(
session
,
1
,
NGHTTP2_STREAM_FLAG_NONE
,
open_recv_stream2
(
session
,
1
,
NGHTTP2_STREAM_OPENING
);
&
pri_spec_default
,
NGHTTP2_STREAM_OPENING
,
NULL
);
nghttp2_submit_response
(
session
,
1
,
NULL
,
0
,
&
data_prd
);
nghttp2_submit_response
(
session
,
1
,
NULL
,
0
,
&
data_prd
);
ud
.
block_count
=
2
;
ud
.
block_count
=
2
;
...
@@ -5519,9 +5494,7 @@ void test_nghttp2_session_defer_data(void) {
...
@@ -5519,9 +5494,7 @@ void test_nghttp2_session_defer_data(void) {
ud
.
data_source_length
=
NGHTTP2_DATA_PAYLOADLEN
*
4
;
ud
.
data_source_length
=
NGHTTP2_DATA_PAYLOADLEN
*
4
;
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
&
ud
);
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
&
ud
);
stream
=
nghttp2_session_open_stream
(
session
,
1
,
NGHTTP2_STREAM_FLAG_NONE
,
stream
=
open_recv_stream2
(
session
,
1
,
NGHTTP2_STREAM_OPENING
);
&
pri_spec_default
,
NGHTTP2_STREAM_OPENING
,
NULL
);
session
->
remote_window_size
=
1
<<
20
;
session
->
remote_window_size
=
1
<<
20
;
stream
->
remote_window_size
=
1
<<
20
;
stream
->
remote_window_size
=
1
<<
20
;
...
@@ -5701,11 +5674,7 @@ void test_nghttp2_session_flow_control_data_recv(void) {
...
@@ -5701,11 +5674,7 @@ void test_nghttp2_session_flow_control_data_recv(void) {
/* Initial window size to 64KiB - 1*/
/* Initial window size to 64KiB - 1*/
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
NULL
);
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
NULL
);
stream
=
nghttp2_session_open_stream
(
session
,
1
,
NGHTTP2_STREAM_FLAG_NONE
,
stream
=
open_sent_stream
(
session
,
1
);
&
pri_spec_default
,
NGHTTP2_STREAM_OPENED
,
NULL
);
session
->
next_stream_id
=
3
;
nghttp2_stream_shutdown
(
stream
,
NGHTTP2_SHUT_WR
);
nghttp2_stream_shutdown
(
stream
,
NGHTTP2_SHUT_WR
);
...
@@ -5771,9 +5740,7 @@ void test_nghttp2_session_flow_control_data_with_padding_recv(void) {
...
@@ -5771,9 +5740,7 @@ void test_nghttp2_session_flow_control_data_with_padding_recv(void) {
nghttp2_option_del
(
option
);
nghttp2_option_del
(
option
);
stream
=
nghttp2_session_open_stream
(
session
,
1
,
NGHTTP2_STREAM_FLAG_NONE
,
stream
=
open_sent_stream
(
session
,
1
);
&
pri_spec_default
,
NGHTTP2_STREAM_OPENED
,
NULL
);
/* Create DATA frame */
/* Create DATA frame */
memset
(
data
,
0
,
sizeof
(
data
));
memset
(
data
,
0
,
sizeof
(
data
));
...
@@ -5914,9 +5881,9 @@ void test_nghttp2_session_on_stream_close(void) {
...
@@ -5914,9 +5881,9 @@ void test_nghttp2_session_on_stream_close(void) {
user_data
.
stream_close_cb_called
=
0
;
user_data
.
stream_close_cb_called
=
0
;
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
&
user_data
);
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
&
user_data
);
stream
=
nghttp2_session_open_stream
(
session
,
1
,
NGHTTP2_STREAM_FLAG_NONE
,
stream
=
&
pri_spec_default
,
NGHTTP2_STREAM_OPENED
,
open_sent_stream3
(
session
,
1
,
NGHTTP2_STREAM_FLAG_NONE
,
&
pri_spec_default
,
&
user_data
);
NGHTTP2_STREAM_OPENED
,
&
user_data
);
CU_ASSERT
(
stream
!=
NULL
);
CU_ASSERT
(
stream
!=
NULL
);
CU_ASSERT
(
nghttp2_session_close_stream
(
session
,
1
,
NGHTTP2_NO_ERROR
)
==
0
);
CU_ASSERT
(
nghttp2_session_close_stream
(
session
,
1
,
NGHTTP2_NO_ERROR
)
==
0
);
CU_ASSERT
(
user_data
.
stream_close_cb_called
==
1
);
CU_ASSERT
(
user_data
.
stream_close_cb_called
==
1
);
...
@@ -5937,9 +5904,9 @@ void test_nghttp2_session_on_ctrl_not_send(void) {
...
@@ -5937,9 +5904,9 @@ void test_nghttp2_session_on_ctrl_not_send(void) {
user_data
.
not_sent_error
=
0
;
user_data
.
not_sent_error
=
0
;
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
&
user_data
);
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
&
user_data
);
stream
=
nghttp2_session_open_stream
(
session
,
1
,
NGHTTP2_STREAM_FLAG_NONE
,
stream
=
&
pri_spec_default
,
open_recv_stream3
(
session
,
1
,
NGHTTP2_STREAM_FLAG_NONE
,
&
pri_spec_default
,
NGHTTP2_STREAM_OPENING
,
&
user_data
);
NGHTTP2_STREAM_OPENING
,
&
user_data
);
/* Check response HEADERS */
/* Check response HEADERS */
/* Send bogus stream ID */
/* Send bogus stream ID */
...
@@ -6024,9 +5991,7 @@ void test_nghttp2_session_get_effective_local_window_size(void) {
...
@@ -6024,9 +5991,7 @@ void test_nghttp2_session_get_effective_local_window_size(void) {
memset
(
&
callbacks
,
0
,
sizeof
(
nghttp2_session_callbacks
));
memset
(
&
callbacks
,
0
,
sizeof
(
nghttp2_session_callbacks
));
CU_ASSERT
(
0
==
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
NULL
));
CU_ASSERT
(
0
==
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
NULL
));
stream
=
nghttp2_session_open_stream
(
session
,
1
,
NGHTTP2_STREAM_FLAG_NONE
,
stream
=
open_sent_stream
(
session
,
1
);
&
pri_spec_default
,
NGHTTP2_STREAM_OPENED
,
NULL
);
CU_ASSERT
(
NGHTTP2_INITIAL_CONNECTION_WINDOW_SIZE
==
CU_ASSERT
(
NGHTTP2_INITIAL_CONNECTION_WINDOW_SIZE
==
nghttp2_session_get_effective_local_window_size
(
session
));
nghttp2_session_get_effective_local_window_size
(
session
));
...
@@ -6180,8 +6145,7 @@ static void check_session_recv_data_with_padding(nghttp2_bufs *bufs,
...
@@ -6180,8 +6145,7 @@ static void check_session_recv_data_with_padding(nghttp2_bufs *bufs,
callbacks
.
on_data_chunk_recv_callback
=
on_data_chunk_recv_callback
;
callbacks
.
on_data_chunk_recv_callback
=
on_data_chunk_recv_callback
;
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
&
ud
);
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
&
ud
);
nghttp2_session_open_stream
(
session
,
1
,
NGHTTP2_STREAM_FLAG_NONE
,
open_recv_stream
(
session
,
1
);
&
pri_spec_default
,
NGHTTP2_STREAM_OPENING
,
NULL
);
inlen
=
(
size_t
)
nghttp2_bufs_remove
(
bufs
,
&
in
);
inlen
=
(
size_t
)
nghttp2_bufs_remove
(
bufs
,
&
in
);
...
@@ -7830,7 +7794,7 @@ void test_nghttp2_session_find_stream(void) {
...
@@ -7830,7 +7794,7 @@ void test_nghttp2_session_find_stream(void) {
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
NULL
);
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
NULL
);
open_stream
(
session
,
1
);
open_
recv_
stream
(
session
,
1
);
stream
=
nghttp2_session_find_stream
(
session
,
1
);
stream
=
nghttp2_session_find_stream
(
session
,
1
);
...
@@ -7865,7 +7829,7 @@ void test_nghttp2_session_keep_closed_stream(void) {
...
@@ -7865,7 +7829,7 @@ void test_nghttp2_session_keep_closed_stream(void) {
nghttp2_submit_settings
(
session
,
NGHTTP2_FLAG_NONE
,
&
iv
,
1
);
nghttp2_submit_settings
(
session
,
NGHTTP2_FLAG_NONE
,
&
iv
,
1
);
for
(
i
=
0
;
i
<
max_concurrent_streams
;
++
i
)
{
for
(
i
=
0
;
i
<
max_concurrent_streams
;
++
i
)
{
open_
stream
(
session
,
(
in
t
)
i
*
2
+
1
);
open_
recv_stream
(
session
,
(
int32_
t
)
i
*
2
+
1
);
}
}
CU_ASSERT
(
0
==
session
->
num_closed_streams
);
CU_ASSERT
(
0
==
session
->
num_closed_streams
);
...
@@ -7888,7 +7852,7 @@ void test_nghttp2_session_keep_closed_stream(void) {
...
@@ -7888,7 +7852,7 @@ void test_nghttp2_session_keep_closed_stream(void) {
session
->
closed_stream_head
->
closed_next
);
session
->
closed_stream_head
->
closed_next
);
CU_ASSERT
(
NULL
==
session
->
closed_stream_head
->
closed_prev
);
CU_ASSERT
(
NULL
==
session
->
closed_stream_head
->
closed_prev
);
open_stream
(
session
,
11
);
open_
recv_
stream
(
session
,
11
);
nghttp2_session_adjust_closed_stream
(
session
);
nghttp2_session_adjust_closed_stream
(
session
);
CU_ASSERT
(
1
==
session
->
num_closed_streams
);
CU_ASSERT
(
1
==
session
->
num_closed_streams
);
...
@@ -7897,7 +7861,7 @@ void test_nghttp2_session_keep_closed_stream(void) {
...
@@ -7897,7 +7861,7 @@ void test_nghttp2_session_keep_closed_stream(void) {
CU_ASSERT
(
NULL
==
session
->
closed_stream_head
->
closed_prev
);
CU_ASSERT
(
NULL
==
session
->
closed_stream_head
->
closed_prev
);
CU_ASSERT
(
NULL
==
session
->
closed_stream_head
->
closed_next
);
CU_ASSERT
(
NULL
==
session
->
closed_stream_head
->
closed_next
);
open_stream
(
session
,
13
);
open_
recv_
stream
(
session
,
13
);
nghttp2_session_adjust_closed_stream
(
session
);
nghttp2_session_adjust_closed_stream
(
session
);
CU_ASSERT
(
0
==
session
->
num_closed_streams
);
CU_ASSERT
(
0
==
session
->
num_closed_streams
);
...
@@ -7910,7 +7874,7 @@ void test_nghttp2_session_keep_closed_stream(void) {
...
@@ -7910,7 +7874,7 @@ void test_nghttp2_session_keep_closed_stream(void) {
CU_ASSERT
(
3
==
session
->
closed_stream_head
->
stream_id
);
CU_ASSERT
(
3
==
session
->
closed_stream_head
->
stream_id
);
/* server initiated stream is not counted to max concurrent limit */
/* server initiated stream is not counted to max concurrent limit */
open_stream
(
session
,
2
);
open_s
ent_s
tream
(
session
,
2
);
nghttp2_session_adjust_closed_stream
(
session
);
nghttp2_session_adjust_closed_stream
(
session
);
CU_ASSERT
(
1
==
session
->
num_closed_streams
);
CU_ASSERT
(
1
==
session
->
num_closed_streams
);
...
@@ -7943,8 +7907,7 @@ void test_nghttp2_session_keep_idle_stream(void) {
...
@@ -7943,8 +7907,7 @@ void test_nghttp2_session_keep_idle_stream(void) {
/* We at least allow NGHTTP2_MIN_IDLE_STREAM idle streams even if
/* We at least allow NGHTTP2_MIN_IDLE_STREAM idle streams even if
max concurrent streams is very low. */
max concurrent streams is very low. */
for
(
i
=
0
;
i
<
NGHTTP2_MIN_IDLE_STREAMS
;
++
i
)
{
for
(
i
=
0
;
i
<
NGHTTP2_MIN_IDLE_STREAMS
;
++
i
)
{
nghttp2_session_open_stream
(
session
,
i
*
2
+
1
,
NGHTTP2_STREAM_FLAG_NONE
,
open_recv_stream2
(
session
,
i
*
2
+
1
,
NGHTTP2_STREAM_IDLE
);
&
pri_spec_default
,
NGHTTP2_STREAM_IDLE
,
NULL
);
nghttp2_session_adjust_idle_stream
(
session
);
nghttp2_session_adjust_idle_stream
(
session
);
}
}
...
@@ -7956,8 +7919,7 @@ void test_nghttp2_session_keep_idle_stream(void) {
...
@@ -7956,8 +7919,7 @@ void test_nghttp2_session_keep_idle_stream(void) {
stream_id
+=
2
;
stream_id
+=
2
;
nghttp2_session_open_stream
(
session
,
stream_id
,
NGHTTP2_FLAG_NONE
,
open_recv_stream2
(
session
,
stream_id
,
NGHTTP2_STREAM_IDLE
);
&
pri_spec_default
,
NGHTTP2_STREAM_IDLE
,
NULL
);
nghttp2_session_adjust_idle_stream
(
session
);
nghttp2_session_adjust_idle_stream
(
session
);
CU_ASSERT
(
NGHTTP2_MIN_IDLE_STREAMS
==
session
->
num_idle_streams
);
CU_ASSERT
(
NGHTTP2_MIN_IDLE_STREAMS
==
session
->
num_idle_streams
);
...
@@ -8089,11 +8051,11 @@ void test_nghttp2_session_graceful_shutdown(void) {
...
@@ -8089,11 +8051,11 @@ void test_nghttp2_session_graceful_shutdown(void) {
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
&
ud
);
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
&
ud
);
open_stream
(
session
,
301
);
open_
recv_
stream
(
session
,
301
);
open_stream
(
session
,
302
);
open_s
ent_s
tream
(
session
,
302
);
open_stream
(
session
,
309
);
open_
recv_
stream
(
session
,
309
);
open_stream
(
session
,
311
);
open_
recv_
stream
(
session
,
311
);
open_stream
(
session
,
319
);
open_
recv_
stream
(
session
,
319
);
CU_ASSERT
(
0
==
nghttp2_submit_shutdown_notice
(
session
));
CU_ASSERT
(
0
==
nghttp2_submit_shutdown_notice
(
session
));
...
@@ -8208,8 +8170,7 @@ void test_nghttp2_session_on_header_temporal_failure(void) {
...
@@ -8208,8 +8170,7 @@ void test_nghttp2_session_on_header_temporal_failure(void) {
nghttp2_hd_deflate_init
(
&
deflater
,
mem
);
nghttp2_hd_deflate_init
(
&
deflater
,
mem
);
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
&
ud
);
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
&
ud
);
nghttp2_session_open_stream
(
session
,
1
,
NGHTTP2_STREAM_FLAG_NONE
,
open_sent_stream
(
session
,
1
);
&
pri_spec_default
,
NGHTTP2_STREAM_OPENING
,
NULL
);
rv
=
pack_push_promise
(
&
bufs
,
&
deflater
,
1
,
NGHTTP2_FLAG_END_HEADERS
,
2
,
rv
=
pack_push_promise
(
&
bufs
,
&
deflater
,
1
,
NGHTTP2_FLAG_END_HEADERS
,
2
,
reqnv
,
ARRLEN
(
reqnv
),
mem
);
reqnv
,
ARRLEN
(
reqnv
),
mem
);
...
@@ -8297,16 +8258,14 @@ void test_nghttp2_session_delete_data_item(void) {
...
@@ -8297,16 +8258,14 @@ void test_nghttp2_session_delete_data_item(void) {
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
NULL
);
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
NULL
);
a
=
open_stream
(
session
,
1
);
a
=
open_
recv_
stream
(
session
,
1
);
open_stream_with_dep
(
session
,
3
,
a
);
open_
recv_
stream_with_dep
(
session
,
3
,
a
);
/* We don't care about these members, since we won't send data */
/* We don't care about these members, since we won't send data */
prd
.
source
.
ptr
=
NULL
;
prd
.
source
.
ptr
=
NULL
;
prd
.
read_callback
=
fail_data_source_read_callback
;
prd
.
read_callback
=
fail_data_source_read_callback
;
/* This data item will be marked as TOP */
CU_ASSERT
(
0
==
nghttp2_submit_data
(
session
,
NGHTTP2_FLAG_NONE
,
1
,
&
prd
));
CU_ASSERT
(
0
==
nghttp2_submit_data
(
session
,
NGHTTP2_FLAG_NONE
,
1
,
&
prd
));
/* This data item will be marked as REST */
CU_ASSERT
(
0
==
nghttp2_submit_data
(
session
,
NGHTTP2_FLAG_NONE
,
3
,
&
prd
));
CU_ASSERT
(
0
==
nghttp2_submit_data
(
session
,
NGHTTP2_FLAG_NONE
,
3
,
&
prd
));
nghttp2_session_del
(
session
);
nghttp2_session_del
(
session
);
...
@@ -8339,9 +8298,7 @@ void test_nghttp2_session_open_idle_stream(void) {
...
@@ -8339,9 +8298,7 @@ void test_nghttp2_session_open_idle_stream(void) {
CU_ASSERT
(
session
->
idle_stream_head
==
stream
);
CU_ASSERT
(
session
->
idle_stream_head
==
stream
);
CU_ASSERT
(
session
->
idle_stream_tail
==
stream
);
CU_ASSERT
(
session
->
idle_stream_tail
==
stream
);
opened_stream
=
nghttp2_session_open_stream
(
opened_stream
=
open_recv_stream2
(
session
,
1
,
NGHTTP2_STREAM_OPENING
);
session
,
1
,
NGHTTP2_STREAM_FLAG_NONE
,
&
pri_spec_default
,
NGHTTP2_STREAM_OPENING
,
NULL
);
CU_ASSERT
(
stream
==
opened_stream
);
CU_ASSERT
(
stream
==
opened_stream
);
CU_ASSERT
(
NGHTTP2_STREAM_OPENING
==
stream
->
state
);
CU_ASSERT
(
NGHTTP2_STREAM_OPENING
==
stream
->
state
);
...
@@ -8376,11 +8333,7 @@ void test_nghttp2_session_cancel_reserved_remote(void) {
...
@@ -8376,11 +8333,7 @@ void test_nghttp2_session_cancel_reserved_remote(void) {
nghttp2_hd_deflate_init
(
&
deflater
,
mem
);
nghttp2_hd_deflate_init
(
&
deflater
,
mem
);
stream
=
nghttp2_session_open_stream
(
session
,
2
,
NGHTTP2_STREAM_FLAG_NONE
,
stream
=
open_recv_stream2
(
session
,
2
,
NGHTTP2_STREAM_RESERVED
);
&
pri_spec_default
,
NGHTTP2_STREAM_RESERVED
,
NULL
);
session
->
last_recv_stream_id
=
2
;
nghttp2_submit_rst_stream
(
session
,
NGHTTP2_FLAG_NONE
,
2
,
NGHTTP2_CANCEL
);
nghttp2_submit_rst_stream
(
session
,
NGHTTP2_FLAG_NONE
,
2
,
NGHTTP2_CANCEL
);
...
@@ -8411,10 +8364,7 @@ void test_nghttp2_session_cancel_reserved_remote(void) {
...
@@ -8411,10 +8364,7 @@ void test_nghttp2_session_cancel_reserved_remote(void) {
/* Check that we can receive push response HEADERS while RST_STREAM
/* Check that we can receive push response HEADERS while RST_STREAM
is just queued. */
is just queued. */
nghttp2_session_open_stream
(
session
,
4
,
NGHTTP2_STREAM_FLAG_NONE
,
open_recv_stream2
(
session
,
4
,
NGHTTP2_STREAM_RESERVED
);
&
pri_spec_default
,
NGHTTP2_STREAM_RESERVED
,
NULL
);
session
->
last_recv_stream_id
=
4
;
nghttp2_submit_rst_stream
(
session
,
NGHTTP2_FLAG_NONE
,
2
,
NGHTTP2_CANCEL
);
nghttp2_submit_rst_stream
(
session
,
NGHTTP2_FLAG_NONE
,
2
,
NGHTTP2_CANCEL
);
...
@@ -8514,8 +8464,7 @@ void test_nghttp2_session_send_data_callback(void) {
...
@@ -8514,8 +8464,7 @@ void test_nghttp2_session_send_data_callback(void) {
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
&
ud
);
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
&
ud
);
nghttp2_session_open_stream
(
session
,
1
,
NGHTTP2_STREAM_FLAG_NONE
,
open_sent_stream
(
session
,
1
);
&
pri_spec_default
,
NGHTTP2_STREAM_OPENING
,
NULL
);
nghttp2_submit_data
(
session
,
NGHTTP2_FLAG_END_STREAM
,
1
,
&
data_prd
);
nghttp2_submit_data
(
session
,
NGHTTP2_FLAG_END_STREAM
,
1
,
&
data_prd
);
...
@@ -8585,8 +8534,7 @@ void test_nghttp2_session_on_begin_headers_temporal_failure(void) {
...
@@ -8585,8 +8534,7 @@ void test_nghttp2_session_on_begin_headers_temporal_failure(void) {
nghttp2_hd_deflate_init
(
&
deflater
,
mem
);
nghttp2_hd_deflate_init
(
&
deflater
,
mem
);
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
&
ud
);
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
&
ud
);
nghttp2_session_open_stream
(
session
,
1
,
NGHTTP2_STREAM_FLAG_NONE
,
open_sent_stream
(
session
,
1
);
&
pri_spec_default
,
NGHTTP2_STREAM_OPENING
,
NULL
);
rv
=
pack_push_promise
(
&
bufs
,
&
deflater
,
1
,
NGHTTP2_FLAG_END_HEADERS
,
2
,
rv
=
pack_push_promise
(
&
bufs
,
&
deflater
,
1
,
NGHTTP2_FLAG_END_HEADERS
,
2
,
reqnv
,
ARRLEN
(
reqnv
),
mem
);
reqnv
,
ARRLEN
(
reqnv
),
mem
);
...
@@ -8682,8 +8630,8 @@ void test_nghttp2_session_detach_item_from_closed_stream(void) {
...
@@ -8682,8 +8630,8 @@ void test_nghttp2_session_detach_item_from_closed_stream(void) {
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
NULL
);
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
NULL
);
open_stream
(
session
,
1
);
open_
recv_
stream
(
session
,
1
);
open_stream
(
session
,
3
);
open_
recv_
stream
(
session
,
3
);
nghttp2_session_close_stream
(
session
,
1
,
NGHTTP2_NO_ERROR
);
nghttp2_session_close_stream
(
session
,
1
,
NGHTTP2_NO_ERROR
);
nghttp2_session_close_stream
(
session
,
3
,
NGHTTP2_NO_ERROR
);
nghttp2_session_close_stream
(
session
,
3
,
NGHTTP2_NO_ERROR
);
...
@@ -8763,9 +8711,9 @@ void test_nghttp2_session_change_stream_priority(void) {
...
@@ -8763,9 +8711,9 @@ void test_nghttp2_session_change_stream_priority(void) {
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
NULL
);
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
NULL
);
stream1
=
open_stream
(
session
,
1
);
stream1
=
open_
recv_
stream
(
session
,
1
);
stream3
=
open_stream_with_dep_weight
(
session
,
3
,
199
,
stream1
);
stream3
=
open_
recv_
stream_with_dep_weight
(
session
,
3
,
199
,
stream1
);
stream2
=
open_stream_with_dep_weight
(
session
,
2
,
101
,
stream3
);
stream2
=
open_s
ent_s
tream_with_dep_weight
(
session
,
2
,
101
,
stream3
);
nghttp2_priority_spec_init
(
&
pri_spec
,
1
,
256
,
0
);
nghttp2_priority_spec_init
(
&
pri_spec
,
1
,
256
,
0
);
...
@@ -8808,7 +8756,7 @@ void test_nghttp2_session_change_stream_priority(void) {
...
@@ -8808,7 +8756,7 @@ void test_nghttp2_session_change_stream_priority(void) {
/* Check that this works in client session too */
/* Check that this works in client session too */
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
NULL
);
nghttp2_session_client_new
(
&
session
,
&
callbacks
,
NULL
);
stream1
=
open_stream
(
session
,
1
);
stream1
=
open_s
ent_s
tream
(
session
,
1
);
nghttp2_priority_spec_init
(
&
pri_spec
,
5
,
9
,
1
);
nghttp2_priority_spec_init
(
&
pri_spec
,
5
,
9
,
1
);
...
@@ -8839,7 +8787,7 @@ void test_nghttp2_session_create_idle_stream(void) {
...
@@ -8839,7 +8787,7 @@ void test_nghttp2_session_create_idle_stream(void) {
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
NULL
);
nghttp2_session_server_new
(
&
session
,
&
callbacks
,
NULL
);
stream2
=
open_stream
(
session
,
2
);
stream2
=
open_s
ent_s
tream
(
session
,
2
);
nghttp2_priority_spec_init
(
&
pri_spec
,
2
,
111
,
1
);
nghttp2_priority_spec_init
(
&
pri_spec
,
2
,
111
,
1
);
...
@@ -9078,9 +9026,11 @@ static void check_nghttp2_http_recv_headers_fail(
...
@@ -9078,9 +9026,11 @@ static void check_nghttp2_http_recv_headers_fail(
ud
=
session
->
user_data
;
ud
=
session
->
user_data
;
if
(
stream_state
!=
-
1
)
{
if
(
stream_state
!=
-
1
)
{
nghttp2_session_open_stream
(
session
,
stream_id
,
NGHTTP2_STREAM_FLAG_NONE
,
if
(
nghttp2_session_is_my_stream_id
(
session
,
stream_id
))
{
&
pri_spec_default
,
open_sent_stream2
(
session
,
stream_id
,
(
nghttp2_stream_state
)
stream_state
);
(
nghttp2_stream_state
)
stream_state
,
NULL
);
}
else
{
open_recv_stream2
(
session
,
stream_id
,
(
nghttp2_stream_state
)
stream_state
);
}
}
}
rv
=
pack_headers
(
&
bufs
,
deflater
,
stream_id
,
NGHTTP2_FLAG_END_HEADERS
,
nva
,
rv
=
pack_headers
(
&
bufs
,
deflater
,
stream_id
,
NGHTTP2_FLAG_END_HEADERS
,
nva
,
...
@@ -9118,9 +9068,11 @@ static void check_nghttp2_http_recv_headers_ok(
...
@@ -9118,9 +9068,11 @@ static void check_nghttp2_http_recv_headers_ok(
ud
=
session
->
user_data
;
ud
=
session
->
user_data
;
if
(
stream_state
!=
-
1
)
{
if
(
stream_state
!=
-
1
)
{
nghttp2_session_open_stream
(
session
,
stream_id
,
NGHTTP2_STREAM_FLAG_NONE
,
if
(
nghttp2_session_is_my_stream_id
(
session
,
stream_id
))
{
&
pri_spec_default
,
open_sent_stream2
(
session
,
stream_id
,
(
nghttp2_stream_state
)
stream_state
);
(
nghttp2_stream_state
)
stream_state
,
NULL
);
}
else
{
open_recv_stream2
(
session
,
stream_id
,
(
nghttp2_stream_state
)
stream_state
);
}
}
}
rv
=
pack_headers
(
&
bufs
,
deflater
,
stream_id
,
NGHTTP2_FLAG_END_HEADERS
,
nva
,
rv
=
pack_headers
(
&
bufs
,
deflater
,
stream_id
,
NGHTTP2_FLAG_END_HEADERS
,
nva
,
...
@@ -9363,9 +9315,7 @@ void test_nghttp2_http_content_length(void) {
...
@@ -9363,9 +9315,7 @@ void test_nghttp2_http_content_length(void) {
nghttp2_hd_deflate_init
(
&
deflater
,
mem
);
nghttp2_hd_deflate_init
(
&
deflater
,
mem
);
stream
=
nghttp2_session_open_stream
(
session
,
1
,
NGHTTP2_STREAM_FLAG_NONE
,
stream
=
open_sent_stream2
(
session
,
1
,
NGHTTP2_STREAM_OPENING
);
&
pri_spec_default
,
NGHTTP2_STREAM_OPENING
,
NULL
);
rv
=
pack_headers
(
&
bufs
,
&
deflater
,
1
,
NGHTTP2_FLAG_END_HEADERS
,
cl_resnv
,
rv
=
pack_headers
(
&
bufs
,
&
deflater
,
1
,
NGHTTP2_FLAG_END_HEADERS
,
cl_resnv
,
ARRLEN
(
cl_resnv
),
mem
);
ARRLEN
(
cl_resnv
),
mem
);
...
@@ -9526,8 +9476,7 @@ void test_nghttp2_http_non_final_response(void) {
...
@@ -9526,8 +9476,7 @@ void test_nghttp2_http_non_final_response(void) {
nghttp2_hd_deflate_init
(
&
deflater
,
mem
);
nghttp2_hd_deflate_init
(
&
deflater
,
mem
);
/* non-final HEADERS with END_STREAM is illegal */
/* non-final HEADERS with END_STREAM is illegal */
nghttp2_session_open_stream
(
session
,
1
,
NGHTTP2_STREAM_FLAG_NONE
,
open_sent_stream2
(
session
,
1
,
NGHTTP2_STREAM_OPENING
);
&
pri_spec_default
,
NGHTTP2_STREAM_OPENING
,
NULL
);
rv
=
pack_headers
(
&
bufs
,
&
deflater
,
1
,
rv
=
pack_headers
(
&
bufs
,
&
deflater
,
1
,
NGHTTP2_FLAG_END_HEADERS
|
NGHTTP2_FLAG_END_STREAM
,
NGHTTP2_FLAG_END_HEADERS
|
NGHTTP2_FLAG_END_STREAM
,
...
@@ -9547,8 +9496,7 @@ void test_nghttp2_http_non_final_response(void) {
...
@@ -9547,8 +9496,7 @@ void test_nghttp2_http_non_final_response(void) {
nghttp2_bufs_reset
(
&
bufs
);
nghttp2_bufs_reset
(
&
bufs
);
/* non-final HEADERS followed by non-empty DATA is illegal */
/* non-final HEADERS followed by non-empty DATA is illegal */
nghttp2_session_open_stream
(
session
,
3
,
NGHTTP2_STREAM_FLAG_NONE
,
open_sent_stream2
(
session
,
3
,
NGHTTP2_STREAM_OPENING
);
&
pri_spec_default
,
NGHTTP2_STREAM_OPENING
,
NULL
);
rv
=
pack_headers
(
&
bufs
,
&
deflater
,
3
,
NGHTTP2_FLAG_END_HEADERS
,
rv
=
pack_headers
(
&
bufs
,
&
deflater
,
3
,
NGHTTP2_FLAG_END_HEADERS
,
nonfinal_resnv
,
ARRLEN
(
nonfinal_resnv
),
mem
);
nonfinal_resnv
,
ARRLEN
(
nonfinal_resnv
),
mem
);
...
@@ -9572,8 +9520,7 @@ void test_nghttp2_http_non_final_response(void) {
...
@@ -9572,8 +9520,7 @@ void test_nghttp2_http_non_final_response(void) {
/* non-final HEADERS followed by empty DATA (without END_STREAM) is
/* non-final HEADERS followed by empty DATA (without END_STREAM) is
ok */
ok */
nghttp2_session_open_stream
(
session
,
5
,
NGHTTP2_STREAM_FLAG_NONE
,
open_sent_stream2
(
session
,
5
,
NGHTTP2_STREAM_OPENING
);
&
pri_spec_default
,
NGHTTP2_STREAM_OPENING
,
NULL
);
rv
=
pack_headers
(
&
bufs
,
&
deflater
,
5
,
NGHTTP2_FLAG_END_HEADERS
,
rv
=
pack_headers
(
&
bufs
,
&
deflater
,
5
,
NGHTTP2_FLAG_END_HEADERS
,
nonfinal_resnv
,
ARRLEN
(
nonfinal_resnv
),
mem
);
nonfinal_resnv
,
ARRLEN
(
nonfinal_resnv
),
mem
);
...
@@ -9594,8 +9541,7 @@ void test_nghttp2_http_non_final_response(void) {
...
@@ -9594,8 +9541,7 @@ void test_nghttp2_http_non_final_response(void) {
/* non-final HEADERS followed by empty DATA (with END_STREAM) is
/* non-final HEADERS followed by empty DATA (with END_STREAM) is
illegal */
illegal */
nghttp2_session_open_stream
(
session
,
7
,
NGHTTP2_STREAM_FLAG_NONE
,
open_sent_stream2
(
session
,
7
,
NGHTTP2_STREAM_OPENING
);
&
pri_spec_default
,
NGHTTP2_STREAM_OPENING
,
NULL
);
rv
=
pack_headers
(
&
bufs
,
&
deflater
,
7
,
NGHTTP2_FLAG_END_HEADERS
,
rv
=
pack_headers
(
&
bufs
,
&
deflater
,
7
,
NGHTTP2_FLAG_END_HEADERS
,
nonfinal_resnv
,
ARRLEN
(
nonfinal_resnv
),
mem
);
nonfinal_resnv
,
ARRLEN
(
nonfinal_resnv
),
mem
);
...
@@ -9619,8 +9565,7 @@ void test_nghttp2_http_non_final_response(void) {
...
@@ -9619,8 +9565,7 @@ void test_nghttp2_http_non_final_response(void) {
nghttp2_bufs_reset
(
&
bufs
);
nghttp2_bufs_reset
(
&
bufs
);
/* non-final HEADERS followed by final HEADERS is OK */
/* non-final HEADERS followed by final HEADERS is OK */
nghttp2_session_open_stream
(
session
,
9
,
NGHTTP2_STREAM_FLAG_NONE
,
open_sent_stream2
(
session
,
9
,
NGHTTP2_STREAM_OPENING
);
&
pri_spec_default
,
NGHTTP2_STREAM_OPENING
,
NULL
);
rv
=
pack_headers
(
&
bufs
,
&
deflater
,
9
,
NGHTTP2_FLAG_END_HEADERS
,
rv
=
pack_headers
(
&
bufs
,
&
deflater
,
9
,
NGHTTP2_FLAG_END_HEADERS
,
nonfinal_resnv
,
ARRLEN
(
nonfinal_resnv
),
mem
);
nonfinal_resnv
,
ARRLEN
(
nonfinal_resnv
),
mem
);
...
@@ -9851,8 +9796,7 @@ void test_nghttp2_http_ignore_content_length(void) {
...
@@ -9851,8 +9796,7 @@ void test_nghttp2_http_ignore_content_length(void) {
nghttp2_hd_deflate_init
(
&
deflater
,
mem
);
nghttp2_hd_deflate_init
(
&
deflater
,
mem
);
/* If status 304, content-length must be ignored */
/* If status 304, content-length must be ignored */
nghttp2_session_open_stream
(
session
,
1
,
NGHTTP2_STREAM_FLAG_NONE
,
open_sent_stream2
(
session
,
1
,
NGHTTP2_STREAM_OPENING
);
&
pri_spec_default
,
NGHTTP2_STREAM_OPENING
,
NULL
);
rv
=
pack_headers
(
&
bufs
,
&
deflater
,
1
,
rv
=
pack_headers
(
&
bufs
,
&
deflater
,
1
,
NGHTTP2_FLAG_END_HEADERS
|
NGHTTP2_FLAG_END_STREAM
,
NGHTTP2_FLAG_END_HEADERS
|
NGHTTP2_FLAG_END_STREAM
,
...
@@ -9969,8 +9913,7 @@ void test_nghttp2_http_push_promise(void) {
...
@@ -9969,8 +9913,7 @@ void test_nghttp2_http_push_promise(void) {
nghttp2_hd_deflate_init
(
&
deflater
,
mem
);
nghttp2_hd_deflate_init
(
&
deflater
,
mem
);
nghttp2_session_open_stream
(
session
,
1
,
NGHTTP2_STREAM_FLAG_NONE
,
open_sent_stream2
(
session
,
1
,
NGHTTP2_STREAM_OPENING
);
&
pri_spec_default
,
NGHTTP2_STREAM_OPENING
,
NULL
);
rv
=
pack_push_promise
(
&
bufs
,
&
deflater
,
1
,
NGHTTP2_FLAG_END_HEADERS
,
2
,
rv
=
pack_push_promise
(
&
bufs
,
&
deflater
,
1
,
NGHTTP2_FLAG_END_HEADERS
,
2
,
reqnv
,
ARRLEN
(
reqnv
),
mem
);
reqnv
,
ARRLEN
(
reqnv
),
mem
);
...
...
tests/nghttp2_test_helper.c
View file @
e14da859
...
@@ -306,3 +306,119 @@ nghttp2_outbound_item *create_data_ob_item(nghttp2_mem *mem) {
...
@@ -306,3 +306,119 @@ nghttp2_outbound_item *create_data_ob_item(nghttp2_mem *mem) {
return
item
;
return
item
;
}
}
nghttp2_stream
*
open_sent_stream
(
nghttp2_session
*
session
,
int32_t
stream_id
)
{
nghttp2_priority_spec
pri_spec
;
nghttp2_priority_spec_init
(
&
pri_spec
,
0
,
NGHTTP2_DEFAULT_WEIGHT
,
0
);
return
open_sent_stream3
(
session
,
stream_id
,
NGHTTP2_FLAG_NONE
,
&
pri_spec
,
NGHTTP2_STREAM_OPENED
,
NULL
);
}
nghttp2_stream
*
open_sent_stream2
(
nghttp2_session
*
session
,
int32_t
stream_id
,
nghttp2_stream_state
initial_state
)
{
nghttp2_priority_spec
pri_spec
;
nghttp2_priority_spec_init
(
&
pri_spec
,
0
,
NGHTTP2_DEFAULT_WEIGHT
,
0
);
return
open_sent_stream3
(
session
,
stream_id
,
NGHTTP2_FLAG_NONE
,
&
pri_spec
,
initial_state
,
NULL
);
}
nghttp2_stream
*
open_sent_stream3
(
nghttp2_session
*
session
,
int32_t
stream_id
,
uint8_t
flags
,
nghttp2_priority_spec
*
pri_spec_in
,
nghttp2_stream_state
initial_state
,
void
*
stream_user_data
)
{
nghttp2_stream
*
stream
;
assert
(
nghttp2_session_is_my_stream_id
(
session
,
stream_id
));
stream
=
nghttp2_session_open_stream
(
session
,
stream_id
,
flags
,
pri_spec_in
,
initial_state
,
stream_user_data
);
session
->
sent_stream_id
=
nghttp2_max
(
session
->
sent_stream_id
,
stream_id
);
session
->
next_stream_id
=
nghttp2_max
(
session
->
next_stream_id
,
(
uint32_t
)
stream_id
+
2
);
return
stream
;
}
nghttp2_stream
*
open_sent_stream_with_dep
(
nghttp2_session
*
session
,
int32_t
stream_id
,
nghttp2_stream
*
dep_stream
)
{
return
open_sent_stream_with_dep_weight
(
session
,
stream_id
,
NGHTTP2_DEFAULT_WEIGHT
,
dep_stream
);
}
nghttp2_stream
*
open_sent_stream_with_dep_weight
(
nghttp2_session
*
session
,
int32_t
stream_id
,
int32_t
weight
,
nghttp2_stream
*
dep_stream
)
{
nghttp2_stream
*
stream
;
assert
(
nghttp2_session_is_my_stream_id
(
session
,
stream_id
));
stream
=
open_stream_with_all
(
session
,
stream_id
,
weight
,
0
,
dep_stream
);
session
->
sent_stream_id
=
nghttp2_max
(
session
->
sent_stream_id
,
stream_id
);
session
->
next_stream_id
=
nghttp2_max
(
session
->
next_stream_id
,
(
uint32_t
)
stream_id
+
2
);
return
stream
;
}
nghttp2_stream
*
open_recv_stream
(
nghttp2_session
*
session
,
int32_t
stream_id
)
{
nghttp2_priority_spec
pri_spec
;
nghttp2_priority_spec_init
(
&
pri_spec
,
0
,
NGHTTP2_DEFAULT_WEIGHT
,
0
);
return
open_recv_stream3
(
session
,
stream_id
,
NGHTTP2_FLAG_NONE
,
&
pri_spec
,
NGHTTP2_STREAM_OPENED
,
NULL
);
}
nghttp2_stream
*
open_recv_stream2
(
nghttp2_session
*
session
,
int32_t
stream_id
,
nghttp2_stream_state
initial_state
)
{
nghttp2_priority_spec
pri_spec
;
nghttp2_priority_spec_init
(
&
pri_spec
,
0
,
NGHTTP2_DEFAULT_WEIGHT
,
0
);
return
open_recv_stream3
(
session
,
stream_id
,
NGHTTP2_FLAG_NONE
,
&
pri_spec
,
initial_state
,
NULL
);
}
nghttp2_stream
*
open_recv_stream3
(
nghttp2_session
*
session
,
int32_t
stream_id
,
uint8_t
flags
,
nghttp2_priority_spec
*
pri_spec_in
,
nghttp2_stream_state
initial_state
,
void
*
stream_user_data
)
{
nghttp2_stream
*
stream
;
assert
(
!
nghttp2_session_is_my_stream_id
(
session
,
stream_id
));
stream
=
nghttp2_session_open_stream
(
session
,
stream_id
,
flags
,
pri_spec_in
,
initial_state
,
stream_user_data
);
session
->
last_recv_stream_id
=
nghttp2_max
(
session
->
last_recv_stream_id
,
stream_id
);
return
stream
;
}
nghttp2_stream
*
open_recv_stream_with_dep
(
nghttp2_session
*
session
,
int32_t
stream_id
,
nghttp2_stream
*
dep_stream
)
{
return
open_recv_stream_with_dep_weight
(
session
,
stream_id
,
NGHTTP2_DEFAULT_WEIGHT
,
dep_stream
);
}
nghttp2_stream
*
open_recv_stream_with_dep_weight
(
nghttp2_session
*
session
,
int32_t
stream_id
,
int32_t
weight
,
nghttp2_stream
*
dep_stream
)
{
nghttp2_stream
*
stream
;
assert
(
!
nghttp2_session_is_my_stream_id
(
session
,
stream_id
));
stream
=
open_stream_with_all
(
session
,
stream_id
,
weight
,
0
,
dep_stream
);
session
->
last_recv_stream_id
=
nghttp2_max
(
session
->
last_recv_stream_id
,
stream_id
);
return
stream
;
}
tests/nghttp2_test_helper.h
View file @
e14da859
...
@@ -110,4 +110,49 @@ nghttp2_stream *open_stream_with_dep_excl(nghttp2_session *session,
...
@@ -110,4 +110,49 @@ nghttp2_stream *open_stream_with_dep_excl(nghttp2_session *session,
nghttp2_outbound_item
*
create_data_ob_item
(
nghttp2_mem
*
mem
);
nghttp2_outbound_item
*
create_data_ob_item
(
nghttp2_mem
*
mem
);
/* Opens stream. This stream is assumed to be sent from |session|,
and session->sent_stream_id and session->next_stream_id will be
adjusted accordingly. */
nghttp2_stream
*
open_sent_stream
(
nghttp2_session
*
session
,
int32_t
stream_id
);
nghttp2_stream
*
open_sent_stream2
(
nghttp2_session
*
session
,
int32_t
stream_id
,
nghttp2_stream_state
initial_state
);
nghttp2_stream
*
open_sent_stream3
(
nghttp2_session
*
session
,
int32_t
stream_id
,
uint8_t
flags
,
nghttp2_priority_spec
*
pri_spec_in
,
nghttp2_stream_state
initial_state
,
void
*
stream_user_data
);
nghttp2_stream
*
open_sent_stream_with_dep
(
nghttp2_session
*
session
,
int32_t
stream_id
,
nghttp2_stream
*
dep_stream
);
nghttp2_stream
*
open_sent_stream_with_dep_weight
(
nghttp2_session
*
session
,
int32_t
stream_id
,
int32_t
weight
,
nghttp2_stream
*
dep_stream
);
/* Opens stream. This stream is assumed to be received by |session|,
and session->last_recv_stream_id will be adjusted accordingly. */
nghttp2_stream
*
open_recv_stream
(
nghttp2_session
*
session
,
int32_t
stream_id
);
nghttp2_stream
*
open_recv_stream2
(
nghttp2_session
*
session
,
int32_t
stream_id
,
nghttp2_stream_state
initial_state
);
nghttp2_stream
*
open_recv_stream3
(
nghttp2_session
*
session
,
int32_t
stream_id
,
uint8_t
flags
,
nghttp2_priority_spec
*
pri_spec_in
,
nghttp2_stream_state
initial_state
,
void
*
stream_user_data
);
nghttp2_stream
*
open_recv_stream_with_dep
(
nghttp2_session
*
session
,
int32_t
stream_id
,
nghttp2_stream
*
dep_stream
);
nghttp2_stream
*
open_recv_stream_with_dep_weight
(
nghttp2_session
*
session
,
int32_t
stream_id
,
int32_t
weight
,
nghttp2_stream
*
dep_stream
);
#endif
/* NGHTTP2_TEST_HELPER_H */
#endif
/* NGHTTP2_TEST_HELPER_H */
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