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
87cadca3
Commit
87cadca3
authored
Apr 10, 2015
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
integration: Add HTTP Upgrade test
parent
9803f92e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
91 additions
and
56 deletions
+91
-56
integration-tests/nghttpx_http2_test.go
integration-tests/nghttpx_http2_test.go
+33
-0
integration-tests/server_tester.go
integration-tests/server_tester.go
+58
-56
No files found.
integration-tests/nghttpx_http2_test.go
View file @
87cadca3
...
@@ -558,6 +558,39 @@ func TestH2H1RequestTrailer(t *testing.T) {
...
@@ -558,6 +558,39 @@ func TestH2H1RequestTrailer(t *testing.T) {
}
}
}
}
// TestH2H1Upgrade tests HTTP Upgrade to HTTP/2
func
TestH2H1Upgrade
(
t
*
testing
.
T
)
{
st
:=
newServerTester
(
nil
,
t
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{})
defer
st
.
Close
()
res
,
err
:=
st
.
http1
(
requestParam
{
name
:
"TestH2H1Upgrade"
,
header
:
[]
hpack
.
HeaderField
{
pair
(
"Connection"
,
"Upgrade, HTTP2-Settings"
),
pair
(
"Upgrade"
,
"h2c-14"
),
pair
(
"HTTP2-Settings"
,
"AAMAAABkAAQAAP__"
),
},
})
if
err
!=
nil
{
t
.
Fatalf
(
"Error st.http1() = %v"
,
err
)
}
if
got
,
want
:=
res
.
status
,
101
;
got
!=
want
{
t
.
Errorf
(
"res.status: %v; want %v"
,
got
,
want
)
}
res
,
err
=
st
.
http2
(
requestParam
{
httpUpgrade
:
true
,
})
if
err
!=
nil
{
t
.
Fatalf
(
"Error st.http2() = %v"
,
err
)
}
if
got
,
want
:=
res
.
status
,
200
;
got
!=
want
{
t
.
Errorf
(
"res.status: %v; want %v"
,
got
,
want
)
}
}
// TestH2H1GracefulShutdown tests graceful shutdown.
// TestH2H1GracefulShutdown tests graceful shutdown.
func
TestH2H1GracefulShutdown
(
t
*
testing
.
T
)
{
func
TestH2H1GracefulShutdown
(
t
*
testing
.
T
)
{
st
:=
newServerTester
(
nil
,
t
,
noopHandler
)
st
:=
newServerTester
(
nil
,
t
,
noopHandler
)
...
...
integration-tests/server_tester.go
View file @
87cadca3
...
@@ -256,6 +256,7 @@ type requestParam struct {
...
@@ -256,6 +256,7 @@ type requestParam struct {
header
[]
hpack
.
HeaderField
// additional request header fields
header
[]
hpack
.
HeaderField
// additional request header fields
body
[]
byte
// request body
body
[]
byte
// request body
trailer
[]
hpack
.
HeaderField
// trailer part
trailer
[]
hpack
.
HeaderField
// trailer part
httpUpgrade
bool
// true if upgraded to HTTP/2 through HTTP Upgrade
}
}
// wrapper for request body to set trailer part
// wrapper for request body to set trailer part
...
@@ -478,6 +479,7 @@ func (st *serverTester) http2(rp requestParam) (*serverResponse, error) {
...
@@ -478,6 +479,7 @@ func (st *serverTester) http2(rp requestParam) (*serverResponse, error) {
streams
:=
make
(
map
[
uint32
]
*
serverResponse
)
streams
:=
make
(
map
[
uint32
]
*
serverResponse
)
streams
[
id
]
=
res
streams
[
id
]
=
res
if
!
rp
.
httpUpgrade
{
method
:=
"GET"
method
:=
"GET"
if
rp
.
method
!=
""
{
if
rp
.
method
!=
""
{
method
=
rp
.
method
method
=
rp
.
method
...
@@ -540,7 +542,7 @@ func (st *serverTester) http2(rp requestParam) (*serverResponse, error) {
...
@@ -540,7 +542,7 @@ func (st *serverTester) http2(rp requestParam) (*serverResponse, error) {
return
nil
,
err
return
nil
,
err
}
}
}
}
}
loop
:
loop
:
for
{
for
{
fr
,
err
:=
st
.
readFrame
()
fr
,
err
:=
st
.
readFrame
()
...
...
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