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
3cc71a70
Commit
3cc71a70
authored
Jul 25, 2013
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename nghttp2_headers_category members
Add NGHTTP2_HCAT_PUSH_RESPONSE
parent
442e10cc
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
45 additions
and
34 deletions
+45
-34
lib/includes/nghttp2/nghttp2.h
lib/includes/nghttp2/nghttp2.h
+15
-12
lib/nghttp2_frame.c
lib/nghttp2_frame.c
+1
-1
lib/nghttp2_session.c
lib/nghttp2_session.c
+19
-15
src/HttpServer.cc
src/HttpServer.cc
+1
-1
src/app_helper.cc
src/app_helper.cc
+6
-2
src/nghttp.cc
src/nghttp.cc
+3
-3
No files found.
lib/includes/nghttp2/nghttp2.h
View file @
3cc71a70
...
...
@@ -449,27 +449,30 @@ typedef struct {
* @enum
*
* The category of HEADERS, which indicates the role of the frame. In
* HTTP/2.0 spec, request HEADERS and response HEADERS and other
* arbitrary sent HEADERS are all called just HEADERS. In SPDY days,
* they are called as SYN_STREAM, SYN_REPLY and HEADERS and which is
* self-explanatory and easy to code. To give the application the
* particular HEADERS frame is analogous to the SPDY terms, we define
* 3 categories for it.
* HTTP/2.0 spec, request, response, push response and other arbitrary
* headers (e.g., trailers) are all called just HEADERS. To give the
* application the role of incoming HEADERS frame, we define several
* categories.
*/
typedef
enum
{
/**
* The HEADERS frame is opening
stream, which is analogous to SPDY
* SYN_STREAM.
* The HEADERS frame is opening
new stream, which is analogous to
* SYN_STREAM
in SPDY
.
*/
NGHTTP2_HCAT_
START_STREAM
,
NGHTTP2_HCAT_
REQUEST
,
/**
* The HEADERS frame is the first response headers, which is
* analogous to S
PDY SYN_REPL
Y.
* analogous to S
YN_REPLY in SPD
Y.
*/
NGHTTP2_HCAT_REPLY
,
NGHTTP2_HCAT_RESPONSE
,
/**
* The HEADERS frame is the first headers sent against reserved
* stream.
*/
NGHTTP2_HCAT_PUSH_RESPONSE
,
/**
* The HEADERS frame which does not apply for the above categories,
* which is analogous to
SPDY HEADERS
.
* which is analogous to
HEADERS in SPDY
.
*/
NGHTTP2_HCAT_HEADERS
,
}
nghttp2_headers_category
;
...
...
lib/nghttp2_frame.c
View file @
3cc71a70
...
...
@@ -203,7 +203,7 @@ void nghttp2_frame_headers_init(nghttp2_headers *frame,
frame
->
pri
=
pri
;
frame
->
nva
=
nva
;
frame
->
nvlen
=
nvlen
;
frame
->
cat
=
NGHTTP2_HCAT_
START_STREAM
;
frame
->
cat
=
NGHTTP2_HCAT_
REQUEST
;
}
void
nghttp2_frame_headers_free
(
nghttp2_headers
*
frame
)
...
...
lib/nghttp2_session.c
View file @
3cc71a70
...
...
@@ -902,11 +902,10 @@ static ssize_t nghttp2_session_prep_frame(nghttp2_session *session,
frame
=
nghttp2_outbound_item_get_ctrl_frame
(
item
);
switch
(
frame
->
hd
.
type
)
{
case
NGHTTP2_HEADERS
:
{
int
push_reply
=
0
;
if
(
frame
->
hd
.
stream_id
==
-
1
)
{
/* initial HEADERS, which opens stream */
int
r
;
frame
->
headers
.
cat
=
NGHTTP2_HCAT_
START_STREAM
;
frame
->
headers
.
cat
=
NGHTTP2_HCAT_
REQUEST
;
r
=
nghttp2_session_predicate_syn_stream_send
(
session
,
&
frame
->
headers
);
if
(
r
!=
0
)
{
...
...
@@ -916,13 +915,10 @@ static ssize_t nghttp2_session_prep_frame(nghttp2_session *session,
session
->
next_stream_id
+=
2
;
}
else
if
(
nghttp2_session_predicate_push_reply_send
(
session
,
frame
->
hd
.
stream_id
)
==
0
)
{
/* HEADERS against promised stream */
push_reply
=
1
;
frame
->
headers
.
cat
=
NGHTTP2_HCAT_REPLY
;
frame
->
headers
.
cat
=
NGHTTP2_HCAT_PUSH_RESPONSE
;
}
else
if
(
nghttp2_session_predicate_syn_reply_send
(
session
,
frame
->
hd
.
stream_id
)
==
0
)
{
/* first response HEADERS */
frame
->
headers
.
cat
=
NGHTTP2_HCAT_REPLY
;
frame
->
headers
.
cat
=
NGHTTP2_HCAT_RESPONSE
;
}
else
{
int
r
;
frame
->
headers
.
cat
=
NGHTTP2_HCAT_HEADERS
;
...
...
@@ -940,7 +936,8 @@ static ssize_t nghttp2_session_prep_frame(nghttp2_session *session,
if
(
framebuflen
<
0
)
{
return
framebuflen
;
}
if
(
frame
->
headers
.
cat
==
NGHTTP2_HCAT_START_STREAM
)
{
switch
(
frame
->
headers
.
cat
)
{
case
NGHTTP2_HCAT_REQUEST
:
{
nghttp2_headers_aux_data
*
aux_data
;
aux_data
=
(
nghttp2_headers_aux_data
*
)
item
->
aux_data
;
if
(
nghttp2_session_open_stream
...
...
@@ -951,7 +948,9 @@ static ssize_t nghttp2_session_prep_frame(nghttp2_session *session,
aux_data
?
aux_data
->
stream_user_data
:
NULL
)
==
NULL
)
{
return
NGHTTP2_ERR_NOMEM
;
}
}
else
if
(
push_reply
)
{
break
;
}
case
NGHTTP2_HCAT_PUSH_RESPONSE
:
{
nghttp2_headers_aux_data
*
aux_data
;
aux_data
=
(
nghttp2_headers_aux_data
*
)
item
->
aux_data
;
if
(
aux_data
)
{
...
...
@@ -959,6 +958,10 @@ static ssize_t nghttp2_session_prep_frame(nghttp2_session *session,
stream
=
nghttp2_session_get_stream
(
session
,
frame
->
hd
.
stream_id
);
stream
->
stream_user_data
=
aux_data
->
stream_user_data
;
}
break
;
}
default:
break
;
}
break
;
}
...
...
@@ -1241,7 +1244,7 @@ static int nghttp2_session_after_frame_sent(nghttp2_session *session)
nghttp2_headers_aux_data
*
aux_data
;
if
(
stream
)
{
switch
(
frame
->
headers
.
cat
)
{
case
NGHTTP2_HCAT_
START_STREAM
:
{
case
NGHTTP2_HCAT_
REQUEST
:
{
stream
->
state
=
NGHTTP2_STREAM_OPENING
;
if
(
frame
->
hd
.
flags
&
NGHTTP2_FLAG_END_STREAM
)
{
nghttp2_stream_shutdown
(
stream
,
NGHTTP2_SHUT_WR
);
...
...
@@ -1263,7 +1266,8 @@ static int nghttp2_session_after_frame_sent(nghttp2_session *session)
}
break
;
}
case
NGHTTP2_HCAT_REPLY
:
case
NGHTTP2_HCAT_RESPONSE
:
case
NGHTTP2_HCAT_PUSH_RESPONSE
:
stream
->
state
=
NGHTTP2_STREAM_OPENED
;
if
(
frame
->
hd
.
flags
&
NGHTTP2_FLAG_END_STREAM
)
{
nghttp2_stream_shutdown
(
stream
,
NGHTTP2_SHUT_WR
);
...
...
@@ -1583,7 +1587,7 @@ static int nghttp2_session_is_new_peer_stream_id(nghttp2_session *session,
/*
* Validates received HEADERS frame |frame| with
* NGHTTP2_HCAT_
START_STREAM
category_. This function returns 0 if it
* NGHTTP2_HCAT_
REQUEST
category_. This function returns 0 if it
* succeeds, or non-zero nghttp2_error_code.
*/
static
int
nghttp2_session_validate_syn_stream
(
nghttp2_session
*
session
,
...
...
@@ -2270,7 +2274,7 @@ static int nghttp2_session_process_ctrl_frame(nghttp2_session *session)
if
(
stream
)
{
if
(
nghttp2_session_is_my_stream_id
(
session
,
frame
.
hd
.
stream_id
))
{
if
(
stream
->
state
==
NGHTTP2_STREAM_OPENING
)
{
frame
.
headers
.
cat
=
NGHTTP2_HCAT_RE
PLY
;
frame
.
headers
.
cat
=
NGHTTP2_HCAT_RE
SPONSE
;
r
=
nghttp2_session_on_syn_reply_received
(
session
,
&
frame
,
stream
);
}
else
{
frame
.
headers
.
cat
=
NGHTTP2_HCAT_HEADERS
;
...
...
@@ -2278,14 +2282,14 @@ static int nghttp2_session_process_ctrl_frame(nghttp2_session *session)
}
}
else
if
(
!
session
->
server
&&
stream
->
state
==
NGHTTP2_STREAM_RESERVED
)
{
frame
.
headers
.
cat
=
NGHTTP2_HCAT_
REPLY
;
frame
.
headers
.
cat
=
NGHTTP2_HCAT_
PUSH_RESPONSE
;
r
=
nghttp2_session_on_push_reply_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_
START_STREAM
;
frame
.
headers
.
cat
=
NGHTTP2_HCAT_
REQUEST
;
r
=
nghttp2_session_on_syn_stream_received
(
session
,
&
frame
);
}
nghttp2_frame_headers_free
(
&
frame
.
headers
);
...
...
src/HttpServer.cc
View file @
3cc71a70
...
...
@@ -687,7 +687,7 @@ void hd_on_frame_recv_callback
switch
(
frame
->
hd
.
type
)
{
case
NGHTTP2_HEADERS
:
switch
(
frame
->
headers
.
cat
)
{
case
NGHTTP2_HCAT_
START_STREAM
:
{
case
NGHTTP2_HCAT_
REQUEST
:
{
int32_t
stream_id
=
frame
->
hd
.
stream_id
;
auto
req
=
util
::
make_unique
<
Request
>
(
stream_id
);
append_nv
(
req
.
get
(),
frame
->
headers
.
nva
,
frame
->
headers
.
nvlen
);
...
...
src/app_helper.cc
View file @
3cc71a70
...
...
@@ -229,14 +229,18 @@ void print_frame(print_type ptype, nghttp2_frame *frame)
printf
(
"(pri=%d)
\n
"
,
frame
->
headers
.
pri
);
}
switch
(
frame
->
headers
.
cat
)
{
case
NGHTTP2_HCAT_
START_STREAM
:
case
NGHTTP2_HCAT_
REQUEST
:
print_frame_attr_indent
();
printf
(
"; Open new stream
\n
"
);
break
;
case
NGHTTP2_HCAT_RE
PLY
:
case
NGHTTP2_HCAT_RE
SPONSE
:
print_frame_attr_indent
();
printf
(
"; First response header
\n
"
);
break
;
case
NGHTTP2_HCAT_PUSH_RESPONSE
:
print_frame_attr_indent
();
printf
(
"; First push response header
\n
"
);
break
;
default:
break
;
}
...
...
src/nghttp.cc
View file @
3cc71a70
...
...
@@ -745,7 +745,7 @@ void on_frame_send_callback2
(
nghttp2_session
*
session
,
nghttp2_frame
*
frame
,
void
*
user_data
)
{
if
(
frame
->
hd
.
type
==
NGHTTP2_HEADERS
&&
frame
->
headers
.
cat
==
NGHTTP2_HCAT_
START_STREAM
)
{
frame
->
headers
.
cat
==
NGHTTP2_HCAT_
REQUEST
)
{
check_stream_id
(
session
,
frame
,
user_data
);
}
if
(
config
.
verbose
)
{
...
...
@@ -757,7 +757,7 @@ void check_response_header
(
nghttp2_session
*
session
,
nghttp2_frame
*
frame
,
void
*
user_data
)
{
if
(
frame
->
hd
.
type
!=
NGHTTP2_HEADERS
||
frame
->
headers
.
cat
!=
NGHTTP2_HCAT_RE
PLY
)
{
frame
->
headers
.
cat
!=
NGHTTP2_HCAT_RE
SPONSE
)
{
return
;
}
auto
req
=
(
Request
*
)
nghttp2_session_get_stream_user_data
...
...
@@ -792,7 +792,7 @@ void on_frame_recv_callback2
(
nghttp2_session
*
session
,
nghttp2_frame
*
frame
,
void
*
user_data
)
{
if
(
frame
->
hd
.
type
==
NGHTTP2_HEADERS
&&
frame
->
headers
.
cat
==
NGHTTP2_HCAT_RE
PLY
)
{
frame
->
headers
.
cat
==
NGHTTP2_HCAT_RE
SPONSE
)
{
auto
req
=
(
Request
*
)
nghttp2_session_get_stream_user_data
(
session
,
frame
->
hd
.
stream_id
);
assert
(
req
);
...
...
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