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
1056d869
Commit
1056d869
authored
Jul 25, 2013
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename functions related to HEADERS
parent
3cc71a70
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
58 additions
and
55 deletions
+58
-55
lib/nghttp2_session.c
lib/nghttp2_session.c
+22
-20
lib/nghttp2_session.h
lib/nghttp2_session.h
+8
-8
tests/main.c
tests/main.c
+6
-6
tests/nghttp2_session_test.c
tests/nghttp2_session_test.c
+19
-18
tests/nghttp2_session_test.h
tests/nghttp2_session_test.h
+3
-3
No files found.
lib/nghttp2_session.c
View file @
1056d869
...
...
@@ -559,7 +559,7 @@ static int nghttp2_predicate_stream_for_send(nghttp2_stream *stream)
* Stream ID has reached the maximum value. Therefore no stream ID
* is available.
*/
static
int
nghttp2_session_predicate_
syn_stream
_send
static
int
nghttp2_session_predicate_
request_headers
_send
(
nghttp2_session
*
session
,
nghttp2_headers
*
frame
)
{
if
(
session
->
goaway_flags
)
{
...
...
@@ -594,8 +594,8 @@ static int nghttp2_session_predicate_syn_stream_send
* The state of the stream is not valid (e.g., SYN_REPLY has
* already sent).
*/
static
int
nghttp2_session_predicate_
syn_reply_send
(
nghttp2_session
*
session
,
int32_t
stream_id
)
static
int
nghttp2_session_predicate_
response_headers_send
(
nghttp2_session
*
session
,
int32_t
stream_id
)
{
nghttp2_stream
*
stream
=
nghttp2_session_get_stream
(
session
,
stream_id
);
int
r
;
...
...
@@ -633,8 +633,8 @@ static int nghttp2_session_predicate_syn_reply_send(nghttp2_session *session,
* NGHTTP2_ERR_STREAM_CLOSED
* RST_STREAM was queued for this stream.
*/
static
int
nghttp2_session_predicate_push_re
ply_send
(
nghttp2_session
*
session
,
int32_t
stream_id
)
static
int
nghttp2_session_predicate_push_re
sponse_headers_send
(
nghttp2_session
*
session
,
int32_t
stream_id
)
{
nghttp2_stream
*
stream
=
nghttp2_session_get_stream
(
session
,
stream_id
);
int
r
;
...
...
@@ -906,17 +906,17 @@ static ssize_t nghttp2_session_prep_frame(nghttp2_session *session,
/* initial HEADERS, which opens stream */
int
r
;
frame
->
headers
.
cat
=
NGHTTP2_HCAT_REQUEST
;
r
=
nghttp2_session_predicate_
syn_stream
_send
(
session
,
&
frame
->
headers
);
r
=
nghttp2_session_predicate_
request_headers
_send
(
session
,
&
frame
->
headers
);
if
(
r
!=
0
)
{
return
r
;
}
frame
->
hd
.
stream_id
=
session
->
next_stream_id
;
session
->
next_stream_id
+=
2
;
}
else
if
(
nghttp2_session_predicate_push_re
ply
_send
}
else
if
(
nghttp2_session_predicate_push_re
sponse_headers
_send
(
session
,
frame
->
hd
.
stream_id
)
==
0
)
{
frame
->
headers
.
cat
=
NGHTTP2_HCAT_PUSH_RESPONSE
;
}
else
if
(
nghttp2_session_predicate_
syn_reply
_send
}
else
if
(
nghttp2_session_predicate_
response_headers
_send
(
session
,
frame
->
hd
.
stream_id
)
==
0
)
{
frame
->
headers
.
cat
=
NGHTTP2_HCAT_RESPONSE
;
}
else
{
...
...
@@ -1654,8 +1654,8 @@ static int nghttp2_session_handle_invalid_connection
return
nghttp2_session_fail_session
(
session
,
error_code
);
}
int
nghttp2_session_on_
syn_stream
_received
(
nghttp2_session
*
session
,
nghttp2_frame
*
frame
)
int
nghttp2_session_on_
request_headers
_received
(
nghttp2_session
*
session
,
nghttp2_frame
*
frame
)
{
int
r
=
0
;
nghttp2_error_code
error_code
=
NGHTTP2_NO_ERROR
;
...
...
@@ -1702,9 +1702,9 @@ int nghttp2_session_on_syn_stream_received(nghttp2_session *session,
return
r
;
}
int
nghttp2_session_on_
syn_reply
_received
(
nghttp2_session
*
session
,
nghttp2_frame
*
frame
,
nghttp2_stream
*
stream
)
int
nghttp2_session_on_
response_headers
_received
(
nghttp2_session
*
session
,
nghttp2_frame
*
frame
,
nghttp2_stream
*
stream
)
{
/* This function is only called if stream->state ==
NGHTTP2_STREAM_OPENING and stream_id is local side initiated. */
...
...
@@ -1736,9 +1736,9 @@ int nghttp2_session_on_syn_reply_received(nghttp2_session *session,
return
0
;
}
int
nghttp2_session_on_push_re
ply
_received
(
nghttp2_session
*
session
,
nghttp2_frame
*
frame
,
nghttp2_stream
*
stream
)
int
nghttp2_session_on_push_re
sponse_headers
_received
(
nghttp2_session
*
session
,
nghttp2_frame
*
frame
,
nghttp2_stream
*
stream
)
{
int
rv
=
0
;
assert
(
!
session
->
server
&&
stream
->
state
==
NGHTTP2_STREAM_RESERVED
);
...
...
@@ -2275,7 +2275,8 @@ static int nghttp2_session_process_ctrl_frame(nghttp2_session *session)
if
(
nghttp2_session_is_my_stream_id
(
session
,
frame
.
hd
.
stream_id
))
{
if
(
stream
->
state
==
NGHTTP2_STREAM_OPENING
)
{
frame
.
headers
.
cat
=
NGHTTP2_HCAT_RESPONSE
;
r
=
nghttp2_session_on_syn_reply_received
(
session
,
&
frame
,
stream
);
r
=
nghttp2_session_on_response_headers_received
(
session
,
&
frame
,
stream
);
}
else
{
frame
.
headers
.
cat
=
NGHTTP2_HCAT_HEADERS
;
r
=
nghttp2_session_on_headers_received
(
session
,
&
frame
,
stream
);
...
...
@@ -2283,14 +2284,15 @@ static int nghttp2_session_process_ctrl_frame(nghttp2_session *session)
}
else
if
(
!
session
->
server
&&
stream
->
state
==
NGHTTP2_STREAM_RESERVED
)
{
frame
.
headers
.
cat
=
NGHTTP2_HCAT_PUSH_RESPONSE
;
r
=
nghttp2_session_on_push_reply_received
(
session
,
&
frame
,
stream
);
r
=
nghttp2_session_on_push_response_headers_received
(
session
,
&
frame
,
stream
);
}
else
{
frame
.
headers
.
cat
=
NGHTTP2_HCAT_HEADERS
;
r
=
nghttp2_session_on_headers_received
(
session
,
&
frame
,
stream
);
}
}
else
{
frame
.
headers
.
cat
=
NGHTTP2_HCAT_REQUEST
;
r
=
nghttp2_session_on_
syn_stream
_received
(
session
,
&
frame
);
r
=
nghttp2_session_on_
request_headers
_received
(
session
,
&
frame
);
}
nghttp2_frame_headers_free
(
&
frame
.
headers
);
nghttp2_hd_end_headers
(
&
session
->
hd_inflater
);
...
...
lib/nghttp2_session.h
View file @
1056d869
...
...
@@ -338,16 +338,16 @@ int nghttp2_session_close_stream_if_shut_rdwr(nghttp2_session *session,
nghttp2_stream
*
stream
);
int
nghttp2_session_on_
syn_stream
_received
(
nghttp2_session
*
session
,
nghttp2_frame
*
frame
);
int
nghttp2_session_on_
request_headers
_received
(
nghttp2_session
*
session
,
nghttp2_frame
*
frame
);
int
nghttp2_session_on_
syn_reply
_received
(
nghttp2_session
*
session
,
nghttp2_frame
*
frame
,
nghttp2_stream
*
stream
);
int
nghttp2_session_on_
response_headers
_received
(
nghttp2_session
*
session
,
nghttp2_frame
*
frame
,
nghttp2_stream
*
stream
);
int
nghttp2_session_on_push_re
ply
_received
(
nghttp2_session
*
session
,
nghttp2_frame
*
frame
,
nghttp2_stream
*
stream
);
int
nghttp2_session_on_push_re
sponse_headers
_received
(
nghttp2_session
*
session
,
nghttp2_frame
*
frame
,
nghttp2_stream
*
stream
);
/*
* Called when HEADERS is received, assuming |frame| is properly
...
...
tests/main.c
View file @
1056d869
...
...
@@ -84,14 +84,14 @@ int main(int argc, char* argv[])
test_nghttp2_session_recv_data
)
||
!
CU_add_test
(
pSuite
,
"session_add_frame"
,
test_nghttp2_session_add_frame
)
||
!
CU_add_test
(
pSuite
,
"session_on_
syn_stream
_received"
,
test_nghttp2_session_on_
syn_stream
_received
)
||
!
CU_add_test
(
pSuite
,
"session_on_
syn_reply
_received"
,
test_nghttp2_session_on_
syn_reply
_received
)
||
!
CU_add_test
(
pSuite
,
"session_on_
request_headers
_received"
,
test_nghttp2_session_on_
request_headers
_received
)
||
!
CU_add_test
(
pSuite
,
"session_on_
response_headers
_received"
,
test_nghttp2_session_on_
response_headers
_received
)
||
!
CU_add_test
(
pSuite
,
"session_on_headers_received"
,
test_nghttp2_session_on_headers_received
)
||
!
CU_add_test
(
pSuite
,
"session_on_push_re
ply
_received"
,
test_nghttp2_session_on_push_re
ply
_received
)
||
!
CU_add_test
(
pSuite
,
"session_on_push_re
sponse_headers
_received"
,
test_nghttp2_session_on_push_re
sponse_headers
_received
)
||
!
CU_add_test
(
pSuite
,
"session_on_priority_received"
,
test_nghttp2_session_on_priority_received
)
||
!
CU_add_test
(
pSuite
,
"session_on_rst_stream_received"
,
...
...
tests/nghttp2_session_test.c
View file @
1056d869
...
...
@@ -602,7 +602,7 @@ void test_nghttp2_session_add_frame(void)
nghttp2_session_del
(
session
);
}
void
test_nghttp2_session_on_
syn_stream
_received
(
void
)
void
test_nghttp2_session_on_
request_headers
_received
(
void
)
{
nghttp2_session
*
session
;
nghttp2_session_callbacks
callbacks
;
...
...
@@ -626,7 +626,7 @@ void test_nghttp2_session_on_syn_stream_received(void)
NGHTTP2_FLAG_END_HEADERS
|
NGHTTP2_FLAG_PRIORITY
,
stream_id
,
1
<<
20
,
nva
,
nvlen
);
CU_ASSERT
(
0
==
nghttp2_session_on_
syn_stream
_received
(
session
,
&
frame
));
CU_ASSERT
(
0
==
nghttp2_session_on_
request_headers
_received
(
session
,
&
frame
));
CU_ASSERT
(
1
==
user_data
.
frame_recv_cb_called
);
stream
=
nghttp2_session_get_stream
(
session
,
stream_id
);
CU_ASSERT
(
NGHTTP2_STREAM_OPENING
==
stream
->
state
);
...
...
@@ -640,7 +640,7 @@ void test_nghttp2_session_on_syn_stream_received(void)
nghttp2_frame_headers_init
(
&
frame
.
headers
,
NGHTTP2_FLAG_END_HEADERS
,
3
,
NGHTTP2_PRI_DEFAULT
,
nva
,
nvlen
);
user_data
.
invalid_frame_recv_cb_called
=
0
;
CU_ASSERT
(
0
==
nghttp2_session_on_
syn_stream
_received
(
session
,
&
frame
));
CU_ASSERT
(
0
==
nghttp2_session_on_
request_headers
_received
(
session
,
&
frame
));
CU_ASSERT
(
1
==
user_data
.
invalid_frame_recv_cb_called
);
CU_ASSERT
(
0
==
(
session
->
goaway_flags
&
NGHTTP2_GOAWAY_FAIL_ON_SEND
));
...
...
@@ -654,7 +654,7 @@ void test_nghttp2_session_on_syn_stream_received(void)
nghttp2_frame_headers_init
(
&
frame
.
headers
,
NGHTTP2_FLAG_END_HEADERS
,
3
,
NGHTTP2_PRI_DEFAULT
,
nva
,
nvlen
);
user_data
.
invalid_frame_recv_cb_called
=
0
;
CU_ASSERT
(
0
==
nghttp2_session_on_
syn_stream
_received
(
session
,
&
frame
));
CU_ASSERT
(
0
==
nghttp2_session_on_
request_headers
_received
(
session
,
&
frame
));
CU_ASSERT
(
1
==
user_data
.
invalid_frame_recv_cb_called
);
CU_ASSERT
(
session
->
goaway_flags
&
NGHTTP2_GOAWAY_FAIL_ON_SEND
);
...
...
@@ -663,7 +663,7 @@ void test_nghttp2_session_on_syn_stream_received(void)
nghttp2_session_del
(
session
);
}
void
test_nghttp2_session_on_
syn_reply
_received
(
void
)
void
test_nghttp2_session_on_
response_headers
_received
(
void
)
{
nghttp2_session
*
session
;
nghttp2_session_callbacks
callbacks
;
...
...
@@ -688,8 +688,8 @@ void test_nghttp2_session_on_syn_reply_received(void)
nghttp2_frame_headers_init
(
&
frame
.
headers
,
NGHTTP2_FLAG_END_HEADERS
,
1
,
NGHTTP2_PRI_DEFAULT
,
nva
,
nvlen
);
CU_ASSERT
(
0
==
nghttp2_session_on_
syn_reply_received
(
session
,
&
frame
,
stream
));
CU_ASSERT
(
0
==
nghttp2_session_on_
response_headers_received
(
session
,
&
frame
,
stream
));
CU_ASSERT
(
1
==
user_data
.
frame_recv_cb_called
);
CU_ASSERT
(
NGHTTP2_STREAM_OPENED
==
stream
->
state
);
...
...
@@ -768,7 +768,7 @@ void test_nghttp2_session_on_headers_received(void)
nghttp2_session_del
(
session
);
}
void
test_nghttp2_session_on_push_re
ply
_received
(
void
)
void
test_nghttp2_session_on_push_re
sponse_headers
_received
(
void
)
{
nghttp2_session
*
session
;
nghttp2_session_callbacks
callbacks
;
...
...
@@ -793,10 +793,11 @@ void test_nghttp2_session_on_push_reply_received(void)
nvlen
=
nghttp2_nv_array_from_cstr
(
&
nva
,
nv
);
nghttp2_frame_headers_init
(
&
frame
.
headers
,
NGHTTP2_FLAG_END_HEADERS
,
2
,
NGHTTP2_PRI_DEFAULT
,
nva
,
nvlen
);
/* nghttp2_session_on_push_reply_received assumes stream's state is
NGHTTP2_STREAM_RESERVED and session->server is 0. */
CU_ASSERT
(
0
==
nghttp2_session_on_push_reply_received
(
session
,
&
frame
,
stream
));
/* nghttp2_session_on_push_response_headers_received assumes
stream's state is NGHTTP2_STREAM_RESERVED and session->server is
0. */
CU_ASSERT
(
0
==
nghttp2_session_on_push_response_headers_received
(
session
,
&
frame
,
stream
));
CU_ASSERT
(
1
==
user_data
.
frame_recv_cb_called
);
CU_ASSERT
(
NGHTTP2_STREAM_OPENED
==
stream
->
state
);
CU_ASSERT
(
1
==
session
->
num_incoming_streams
);
...
...
@@ -807,8 +808,8 @@ void test_nghttp2_session_on_push_reply_received(void)
NGHTTP2_PRI_DEFAULT
,
NGHTTP2_STREAM_RESERVED
,
NULL
);
frame
.
hd
.
stream_id
=
4
;
CU_ASSERT
(
0
==
nghttp2_session_on_push_re
ply_received
(
session
,
&
frame
,
stream
));
CU_ASSERT
(
0
==
nghttp2_session_on_push_re
sponse_headers_received
(
session
,
&
frame
,
stream
));
item
=
nghttp2_session_get_next_ob_item
(
session
);
CU_ASSERT
(
NGHTTP2_RST_STREAM
==
OB_CTRL_TYPE
(
item
));
CU_ASSERT
(
NGHTTP2_REFUSED_STREAM
==
OB_CTRL
(
item
)
->
rst_stream
.
error_code
);
...
...
@@ -2155,7 +2156,7 @@ void test_nghttp2_session_max_concurrent_streams(void)
NGHTTP2_PRI_DEFAULT
,
nva
,
nvlen
);
session
->
local_settings
[
NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS
]
=
1
;
CU_ASSERT
(
0
==
nghttp2_session_on_
syn_stream
_received
(
session
,
&
frame
));
CU_ASSERT
(
0
==
nghttp2_session_on_
request_headers
_received
(
session
,
&
frame
));
item
=
nghttp2_session_get_ob_pq_top
(
session
);
CU_ASSERT
(
NGHTTP2_RST_STREAM
==
OB_CTRL_TYPE
(
item
));
...
...
@@ -2190,7 +2191,7 @@ void test_nghttp2_session_stream_close_on_headers_push(void)
/* NGHTTP2_CTRL_FLAG_UNIDIRECTIONAL, */
/* 2, 1, 3, dup_nv(nv)); */
/* CU_ASSERT(0 == nghttp2_session_on_
syn_stream
_received(session, &frame)); */
/* CU_ASSERT(0 == nghttp2_session_on_
request_headers
_received(session, &frame)); */
/* nghttp2_frame_syn_stream_free(&frame.syn_stream); */
/* nghttp2_session_del(session); */
...
...
@@ -2547,13 +2548,13 @@ void test_nghttp2_session_on_request_recv_callback(void)
nvlen
=
nghttp2_nv_array_from_cstr
(
&
nva
,
nv
);
nghttp2_frame_headers_init
(
&
frame
.
headers
,
NGHTTP2_FLAG_END_HEADERS
,
1
,
NGHTTP2_PRI_DEFAULT
,
nva
,
nvlen
);
CU_ASSERT
(
0
==
nghttp2_session_on_
syn_stream
_received
(
session
,
&
frame
));
CU_ASSERT
(
0
==
nghttp2_session_on_
request_headers
_received
(
session
,
&
frame
));
CU_ASSERT
(
0
==
user_data
.
stream_id
);
frame
.
hd
.
stream_id
=
3
;
frame
.
hd
.
flags
|=
NGHTTP2_FLAG_END_STREAM
;
CU_ASSERT
(
0
==
nghttp2_session_on_
syn_stream
_received
(
session
,
&
frame
));
CU_ASSERT
(
0
==
nghttp2_session_on_
request_headers
_received
(
session
,
&
frame
));
CU_ASSERT
(
3
==
user_data
.
stream_id
);
nghttp2_frame_headers_free
(
&
frame
.
headers
);
...
...
tests/nghttp2_session_test.h
View file @
1056d869
...
...
@@ -31,10 +31,10 @@ void test_nghttp2_session_recv_invalid_frame(void);
void
test_nghttp2_session_recv_eof
(
void
);
void
test_nghttp2_session_recv_data
(
void
);
void
test_nghttp2_session_add_frame
(
void
);
void
test_nghttp2_session_on_
syn_stream
_received
(
void
);
void
test_nghttp2_session_on_
syn_reply
_received
(
void
);
void
test_nghttp2_session_on_
request_headers
_received
(
void
);
void
test_nghttp2_session_on_
response_headers
_received
(
void
);
void
test_nghttp2_session_on_headers_received
(
void
);
void
test_nghttp2_session_on_push_re
ply
_received
(
void
);
void
test_nghttp2_session_on_push_re
sponse_headers
_received
(
void
);
void
test_nghttp2_session_on_priority_received
(
void
);
void
test_nghttp2_session_on_rst_stream_received
(
void
);
void
test_nghttp2_session_on_settings_received
(
void
);
...
...
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