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
0735ec55
Commit
0735ec55
authored
Oct 17, 2018
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nghttpx: Convert shrpx_connect_proto to enum class
parent
00554779
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
27 additions
and
24 deletions
+27
-24
src/shrpx_downstream.cc
src/shrpx_downstream.cc
+3
-3
src/shrpx_downstream.h
src/shrpx_downstream.h
+9
-7
src/shrpx_http2_downstream_connection.cc
src/shrpx_http2_downstream_connection.cc
+7
-6
src/shrpx_http2_session.cc
src/shrpx_http2_session.cc
+2
-2
src/shrpx_http2_upstream.cc
src/shrpx_http2_upstream.cc
+2
-2
src/shrpx_http_downstream_connection.cc
src/shrpx_http_downstream_connection.cc
+2
-2
src/shrpx_https_upstream.cc
src/shrpx_https_upstream.cc
+2
-2
No files found.
src/shrpx_downstream.cc
View file @
0735ec55
...
...
@@ -767,13 +767,13 @@ void Downstream::check_upgrade_fulfilled_http2() {
// This handles nonzero req_.connect_proto and h1 frontend requests
// WebSocket upgrade.
upgraded_
=
(
req_
.
method
==
HTTP_CONNECT
||
req_
.
connect_proto
==
C
ONNECT_PROTO_
WEBSOCKET
)
&&
req_
.
connect_proto
==
C
onnectProto
::
WEBSOCKET
)
&&
resp_
.
http_status
/
100
==
2
;
}
void
Downstream
::
check_upgrade_fulfilled_http1
()
{
if
(
req_
.
method
==
HTTP_CONNECT
)
{
if
(
req_
.
connect_proto
==
C
ONNECT_PROTO_
WEBSOCKET
)
{
if
(
req_
.
connect_proto
==
C
onnectProto
::
WEBSOCKET
)
{
if
(
resp_
.
http_status
!=
101
)
{
return
;
}
...
...
@@ -827,7 +827,7 @@ void Downstream::inspect_http1_request() {
// TODO Should we check Sec-WebSocket-Key, and
// Sec-WebSocket-Version as well?
if
(
util
::
strieq_l
(
"websocket"
,
val
))
{
req_
.
connect_proto
=
C
ONNECT_PROTO_
WEBSOCKET
;
req_
.
connect_proto
=
C
onnectProto
::
WEBSOCKET
;
}
}
}
...
...
src/shrpx_downstream.h
View file @
0735ec55
...
...
@@ -135,9 +135,9 @@ private:
};
// Protocols allowed in HTTP/2 :protocol header field.
enum
shrpx_connect_p
roto
{
CONNECT_PROTO_
NONE
,
CONNECT_PROTO_
WEBSOCKET
,
enum
class
ConnectP
roto
{
NONE
,
WEBSOCKET
,
};
struct
Request
{
...
...
@@ -148,7 +148,7 @@ struct Request {
method
(
-
1
),
http_major
(
1
),
http_minor
(
1
),
connect_proto
(
C
ONNECT_PROTO_
NONE
),
connect_proto
(
C
onnectProto
::
NONE
),
upgrade_request
(
false
),
http2_upgrade_seen
(
false
),
connection_close
(
false
),
...
...
@@ -161,10 +161,12 @@ struct Request {
}
bool
regular_connect_method
()
const
{
return
method
==
HTTP_CONNECT
&&
!
connect_proto
;
return
method
==
HTTP_CONNECT
&&
connect_proto
==
ConnectProto
::
NONE
;
}
bool
extended_connect_method
()
const
{
return
connect_proto
;
}
bool
extended_connect_method
()
const
{
return
connect_proto
!=
ConnectProto
::
NONE
;
}
FieldStore
fs
;
// Timestamp when all request header fields are received.
...
...
@@ -192,7 +194,7 @@ struct Request {
// connect_proto specified in HTTP/2 :protocol pseudo header field
// which enables extended CONNECT method. This field is also set if
// WebSocket upgrade is requested in h1 frontend for convenience.
int
connect_proto
;
ConnectProto
connect_proto
;
// Returns true if the request is HTTP upgrade (HTTP Upgrade or
// CONNECT method). Upgrade to HTTP/2 is excluded. For HTTP/2
// Upgrade, check get_http2_upgrade_request().
...
...
src/shrpx_http2_downstream_connection.cc
View file @
0735ec55
...
...
@@ -105,7 +105,7 @@ int Http2DownstreamConnection::attach_downstream(Downstream *downstream) {
auto
&
req
=
downstream_
->
request
();
// HTTP/2 disables HTTP Upgrade.
if
(
req
.
method
!=
HTTP_CONNECT
&&
!
req
.
connect_proto
)
{
if
(
req
.
method
!=
HTTP_CONNECT
&&
req
.
connect_proto
==
ConnectProto
::
NONE
)
{
req
.
upgrade_request
=
false
;
}
...
...
@@ -244,7 +244,8 @@ int Http2DownstreamConnection::push_request_headers() {
const
auto
&
req
=
downstream_
->
request
();
if
(
req
.
connect_proto
&&
!
http2session_
->
get_allow_connect_proto
())
{
if
(
req
.
connect_proto
!=
ConnectProto
::
NONE
&&
!
http2session_
->
get_allow_connect_proto
())
{
return
-
1
;
}
...
...
@@ -292,7 +293,7 @@ int Http2DownstreamConnection::push_request_headers() {
nva
.
reserve
(
req
.
fs
.
headers
().
size
()
+
11
+
num_cookies
+
httpconf
.
add_request_headers
.
size
());
if
(
req
.
connect_proto
==
C
ONNECT_PROTO_
WEBSOCKET
)
{
if
(
req
.
connect_proto
==
C
onnectProto
::
WEBSOCKET
)
{
nva
.
push_back
(
http2
::
make_nv_ll
(
":method"
,
"CONNECT"
));
nva
.
push_back
(
http2
::
make_nv_ll
(
":protocol"
,
"websocket"
));
}
else
{
...
...
@@ -318,7 +319,7 @@ int Http2DownstreamConnection::push_request_headers() {
nva
.
push_back
(
http2
::
make_nv_ls_nocopy
(
":path"
,
req
.
path
));
}
if
(
!
req
.
no_authority
||
req
.
connect_proto
)
{
if
(
!
req
.
no_authority
||
req
.
connect_proto
!=
ConnectProto
::
NONE
)
{
nva
.
push_back
(
http2
::
make_nv_ls_nocopy
(
":authority"
,
authority
));
}
else
{
nva
.
push_back
(
http2
::
make_nv_ls_nocopy
(
"host"
,
authority
));
...
...
@@ -475,8 +476,8 @@ int Http2DownstreamConnection::push_request_headers() {
// Add body as long as transfer-encoding is given even if
// req.fs.content_length == 0 to forward trailer fields.
if
(
req
.
method
==
HTTP_CONNECT
||
req
.
connect_proto
||
transfer_encoding
||
req
.
fs
.
content_length
>
0
||
req
.
http2_expect_body
)
{
if
(
req
.
method
==
HTTP_CONNECT
||
req
.
connect_proto
!=
ConnectProto
::
NONE
||
transfer_encoding
||
req
.
fs
.
content_length
>
0
||
req
.
http2_expect_body
)
{
// Request-body is expected.
data_prd
=
{{},
http2_data_read_callback
};
data_prdptr
=
&
data_prd
;
...
...
src/shrpx_http2_session.cc
View file @
0735ec55
...
...
@@ -1859,7 +1859,7 @@ bool Http2Session::can_push_request(const Downstream *downstream) const {
auto
&
req
=
downstream
->
request
();
return
state_
==
CONNECTED
&&
connection_check_state_
==
CONNECTION_CHECK_NONE
&&
(
!
req
.
connect_proto
||
settings_recved_
);
(
req
.
connect_proto
==
ConnectProto
::
NONE
||
settings_recved_
);
}
void
Http2Session
::
start_checking_connection
()
{
...
...
@@ -1919,7 +1919,7 @@ void Http2Session::submit_pending_requests() {
}
auto
&
req
=
downstream
->
request
();
if
(
req
.
connect_proto
&&
!
settings_recved_
)
{
if
(
req
.
connect_proto
!=
ConnectProto
::
NONE
&&
!
settings_recved_
)
{
continue
;
}
...
...
src/shrpx_http2_upstream.cc
View file @
0735ec55
...
...
@@ -400,7 +400,7 @@ int Http2Upstream::on_request_headers(Downstream *downstream,
}
return
0
;
}
req
.
connect_proto
=
C
ONNECT_PROTO_
WEBSOCKET
;
req
.
connect_proto
=
C
onnectProto
::
WEBSOCKET
;
}
if
(
!
(
frame
->
hd
.
flags
&
NGHTTP2_FLAG_END_STREAM
))
{
...
...
@@ -1752,7 +1752,7 @@ int Http2Upstream::on_downstream_header_complete(Downstream *downstream) {
auto
striphd_flags
=
http2
::
HDOP_STRIP_ALL
&
~
http2
::
HDOP_STRIP_VIA
;
StringRef
response_status
;
if
(
req
.
connect_proto
==
C
ONNECT_PROTO_
WEBSOCKET
&&
resp
.
http_status
==
101
)
{
if
(
req
.
connect_proto
==
C
onnectProto
::
WEBSOCKET
&&
resp
.
http_status
==
101
)
{
response_status
=
http2
::
stringify_status
(
balloc
,
200
);
striphd_flags
|=
http2
::
HDOP_STRIP_SEC_WEBSOCKET_ACCEPT
;
}
else
{
...
...
src/shrpx_http_downstream_connection.cc
View file @
0735ec55
...
...
@@ -513,7 +513,7 @@ int HttpDownstreamConnection::push_request_headers() {
// Assume that method and request path do not contain \r\n.
auto
meth
=
http2
::
to_method_string
(
req
.
connect_proto
==
C
ONNECT_PROTO_
WEBSOCKET
?
HTTP_GET
:
req
.
method
);
req
.
connect_proto
==
C
onnectProto
::
WEBSOCKET
?
HTTP_GET
:
req
.
method
);
buf
->
append
(
meth
);
buf
->
append
(
' '
);
...
...
@@ -566,7 +566,7 @@ int HttpDownstreamConnection::push_request_headers() {
buf
->
append
(
"Transfer-Encoding: chunked
\r\n
"
);
}
if
(
req
.
connect_proto
==
C
ONNECT_PROTO_
WEBSOCKET
)
{
if
(
req
.
connect_proto
==
C
onnectProto
::
WEBSOCKET
)
{
if
(
req
.
http_major
==
2
)
{
std
::
array
<
uint8_t
,
16
>
nonce
;
util
::
random_bytes
(
std
::
begin
(
nonce
),
std
::
end
(
nonce
),
...
...
src/shrpx_https_upstream.cc
View file @
0735ec55
...
...
@@ -1091,7 +1091,7 @@ int HttpsUpstream::on_downstream_header_complete(Downstream *downstream) {
buf
->
append
(
'.'
);
buf
->
append
(
'0'
+
req
.
http_minor
);
buf
->
append
(
' '
);
if
(
req
.
connect_proto
&&
downstream
->
get_upgraded
())
{
if
(
req
.
connect_proto
!=
ConnectProto
::
NONE
&&
downstream
->
get_upgraded
())
{
buf
->
append
(
http2
::
stringify_status
(
balloc
,
101
));
buf
->
append
(
' '
);
buf
->
append
(
http2
::
get_reason_phrase
(
101
));
...
...
@@ -1153,7 +1153,7 @@ int HttpsUpstream::on_downstream_header_complete(Downstream *downstream) {
}
if
(
!
connect_method
&&
downstream
->
get_upgraded
())
{
if
(
req
.
connect_proto
==
C
ONNECT_PROTO_
WEBSOCKET
&&
if
(
req
.
connect_proto
==
C
onnectProto
::
WEBSOCKET
&&
resp
.
http_status
/
100
==
2
)
{
buf
->
append
(
"Upgrade: websocket
\r\n
Connection: Upgrade
\r\n
"
);
auto
key
=
req
.
fs
.
header
(
http2
::
HD_SEC_WEBSOCKET_KEY
);
...
...
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