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
cf5ac0f3
Commit
cf5ac0f3
authored
Mar 01, 2015
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nghttpx: Fix broken server push after HTTP upgrade
parent
185ebd7b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
7 deletions
+45
-7
src/shrpx_http2_upstream.cc
src/shrpx_http2_upstream.cc
+45
-7
No files found.
src/shrpx_http2_upstream.cc
View file @
cf5ac0f3
...
@@ -106,6 +106,35 @@ int on_stream_close_callback(nghttp2_session *session, int32_t stream_id,
...
@@ -106,6 +106,35 @@ int on_stream_close_callback(nghttp2_session *session, int32_t stream_id,
int
Http2Upstream
::
upgrade_upstream
(
HttpsUpstream
*
http
)
{
int
Http2Upstream
::
upgrade_upstream
(
HttpsUpstream
*
http
)
{
int
rv
;
int
rv
;
// to deduce :scheme and :authority, first we have to parse request
// URI.
http_parser_url
u
=
{};
auto
&
url
=
http
->
get_downstream
()
->
get_request_path
();
std
::
string
scheme
,
authority
;
rv
=
http_parser_parse_url
(
url
.
c_str
(),
url
.
size
(),
0
,
&
u
);
if
(
rv
==
0
)
{
http2
::
copy_url_component
(
scheme
,
&
u
,
UF_SCHEMA
,
url
.
c_str
());
http2
::
copy_url_component
(
authority
,
&
u
,
UF_HOST
,
url
.
c_str
());
}
if
(
scheme
.
empty
())
{
if
(
handler_
->
get_ssl
())
{
scheme
=
"https"
;
}
else
{
scheme
=
"http"
;
}
}
if
(
!
authority
.
empty
())
{
if
(
authority
.
find
(
":"
)
!=
std
::
string
::
npos
)
{
authority
=
"["
+
authority
;
authority
+=
"]"
;
}
if
(
u
.
field_set
&
(
1
<<
UF_PORT
))
{
authority
+=
":"
;
authority
+=
util
::
utos
(
u
.
port
);
}
}
auto
http2_settings
=
http
->
get_downstream
()
->
get_http2_settings
();
auto
http2_settings
=
http
->
get_downstream
()
->
get_http2_settings
();
util
::
to_base64
(
http2_settings
);
util
::
to_base64
(
http2_settings
);
...
@@ -129,6 +158,8 @@ int Http2Upstream::upgrade_upstream(HttpsUpstream *http) {
...
@@ -129,6 +158,8 @@ int Http2Upstream::upgrade_upstream(HttpsUpstream *http) {
downstream
->
reset_upstream_rtimer
();
downstream
->
reset_upstream_rtimer
();
downstream
->
set_stream_id
(
1
);
downstream
->
set_stream_id
(
1
);
downstream
->
set_priority
(
0
);
downstream
->
set_priority
(
0
);
downstream
->
set_request_http2_authority
(
authority
);
downstream
->
set_request_http2_scheme
(
scheme
);
downstream_queue_
.
add_active
(
std
::
move
(
downstream
));
downstream_queue_
.
add_active
(
std
::
move
(
downstream
));
...
@@ -1525,11 +1556,25 @@ int Http2Upstream::submit_push_promise(const std::string &path,
...
@@ -1525,11 +1556,25 @@ int Http2Upstream::submit_push_promise(const std::string &path,
int
rv
;
int
rv
;
std
::
vector
<
nghttp2_nv
>
nva
;
std
::
vector
<
nghttp2_nv
>
nva
;
nva
.
reserve
(
downstream
->
get_request_headers
().
size
());
nva
.
reserve
(
downstream
->
get_request_headers
().
size
());
// juse use "GET" for now
nva
.
push_back
(
http2
::
make_nv_ll
(
":method"
,
"GET"
));
nva
.
push_back
(
http2
::
make_nv
(
":scheme"
,
downstream
->
get_request_http2_scheme
()));
nva
.
push_back
(
http2
::
make_nv_ls
(
":path"
,
path
));
auto
&
authority
=
downstream
->
get_request_http2_authority
();
if
(
!
authority
.
empty
())
{
nva
.
push_back
(
http2
::
make_nv
(
":authority"
,
authority
));
}
for
(
auto
&
kv
:
downstream
->
get_request_headers
())
{
for
(
auto
&
kv
:
downstream
->
get_request_headers
())
{
switch
(
kv
.
token
)
{
switch
(
kv
.
token
)
{
// TODO generate referer
// TODO generate referer
case
http2
:
:
HD__AUTHORITY
:
case
http2
:
:
HD__AUTHORITY
:
case
http2
:
:
HD__SCHEME
:
case
http2
:
:
HD__SCHEME
:
case
http2
:
:
HD__METHOD
:
case
http2
:
:
HD__PATH
:
continue
;
case
http2
:
:
HD_ACCEPT_ENCODING
:
case
http2
:
:
HD_ACCEPT_ENCODING
:
case
http2
:
:
HD_ACCEPT_LANGUAGE
:
case
http2
:
:
HD_ACCEPT_LANGUAGE
:
case
http2
:
:
HD_CACHE_CONTROL
:
case
http2
:
:
HD_CACHE_CONTROL
:
...
@@ -1537,13 +1582,6 @@ int Http2Upstream::submit_push_promise(const std::string &path,
...
@@ -1537,13 +1582,6 @@ int Http2Upstream::submit_push_promise(const std::string &path,
case
http2
:
:
HD_USER_AGENT
:
case
http2
:
:
HD_USER_AGENT
:
nva
.
push_back
(
http2
::
make_nv
(
kv
.
name
,
kv
.
value
,
kv
.
no_index
));
nva
.
push_back
(
http2
::
make_nv
(
kv
.
name
,
kv
.
value
,
kv
.
no_index
));
break
;
break
;
case
http2
:
:
HD__METHOD
:
// juse use "GET" for now
nva
.
push_back
(
http2
::
make_nv_lc
(
":method"
,
"GET"
));
continue
;
case
http2
:
:
HD__PATH
:
nva
.
push_back
(
http2
::
make_nv_ls
(
":path"
,
path
));
continue
;
}
}
}
}
...
...
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