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
e2a7e867
Commit
e2a7e867
authored
Apr 07, 2017
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
integration: Add more tests for 204 status code
parent
32ce0ce5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
100 additions
and
0 deletions
+100
-0
integration-tests/nghttpx_http2_test.go
integration-tests/nghttpx_http2_test.go
+100
-0
No files found.
integration-tests/nghttpx_http2_test.go
View file @
e2a7e867
...
...
@@ -1568,6 +1568,106 @@ func TestH2H1Code204(t *testing.T) {
}
}
// TestH2H1Code204CL0 tests that 204 response with content-length: 0
// is allowed.
func
TestH2H1Code204CL0
(
t
*
testing
.
T
)
{
st
:=
newServerTester
(
nil
,
t
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
hj
,
ok
:=
w
.
(
http
.
Hijacker
)
if
!
ok
{
http
.
Error
(
w
,
"Could not hijack the connection"
,
http
.
StatusInternalServerError
)
return
}
conn
,
bufrw
,
err
:=
hj
.
Hijack
()
if
err
!=
nil
{
http
.
Error
(
w
,
err
.
Error
(),
http
.
StatusInternalServerError
)
return
}
defer
conn
.
Close
()
bufrw
.
WriteString
(
"HTTP/1.1 204
\r\n
Content-Length: 0
\r\n\r\n
"
)
bufrw
.
Flush
()
})
defer
st
.
Close
()
res
,
err
:=
st
.
http2
(
requestParam
{
name
:
"TestH2H1Code204CL0"
,
})
if
err
!=
nil
{
t
.
Fatalf
(
"Error st.http2() = %v"
,
err
)
}
if
got
,
want
:=
res
.
status
,
204
;
got
!=
want
{
t
.
Errorf
(
"status = %v; want %v"
,
got
,
want
)
}
if
got
,
found
:=
res
.
header
[
"Content-Length"
];
found
{
t
.
Errorf
(
"Content-Length = %v, want nothing"
,
got
)
}
}
// TestH2H1Code204CLNonzero tests that 204 response with nonzero
// content-length is not allowed.
func
TestH2H1Code204CLNonzero
(
t
*
testing
.
T
)
{
st
:=
newServerTester
(
nil
,
t
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
hj
,
ok
:=
w
.
(
http
.
Hijacker
)
if
!
ok
{
http
.
Error
(
w
,
"Could not hijack the connection"
,
http
.
StatusInternalServerError
)
return
}
conn
,
bufrw
,
err
:=
hj
.
Hijack
()
if
err
!=
nil
{
http
.
Error
(
w
,
err
.
Error
(),
http
.
StatusInternalServerError
)
return
}
defer
conn
.
Close
()
bufrw
.
WriteString
(
"HTTP/1.1 204
\r\n
Content-Length: 1
\r\n\r\n
"
)
bufrw
.
Flush
()
})
defer
st
.
Close
()
res
,
err
:=
st
.
http2
(
requestParam
{
name
:
"TestH2H1Code204CLNonzero"
,
})
if
err
!=
nil
{
t
.
Fatalf
(
"Error st.http2() = %v"
,
err
)
}
if
got
,
want
:=
res
.
status
,
502
;
got
!=
want
{
t
.
Errorf
(
"status = %v; want %v"
,
got
,
want
)
}
}
// TestH2H1Code204TE tests that 204 response with transfer-encoding is
// not allowed.
func
TestH2H1Code204TE
(
t
*
testing
.
T
)
{
st
:=
newServerTester
(
nil
,
t
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
hj
,
ok
:=
w
.
(
http
.
Hijacker
)
if
!
ok
{
http
.
Error
(
w
,
"Could not hijack the connection"
,
http
.
StatusInternalServerError
)
return
}
conn
,
bufrw
,
err
:=
hj
.
Hijack
()
if
err
!=
nil
{
http
.
Error
(
w
,
err
.
Error
(),
http
.
StatusInternalServerError
)
return
}
defer
conn
.
Close
()
bufrw
.
WriteString
(
"HTTP/1.1 204
\r\n
Transfer-Encoding: chunked
\r\n\r\n
"
)
bufrw
.
Flush
()
})
defer
st
.
Close
()
res
,
err
:=
st
.
http2
(
requestParam
{
name
:
"TestH2H1Code204TE"
,
})
if
err
!=
nil
{
t
.
Fatalf
(
"Error st.http2() = %v"
,
err
)
}
if
got
,
want
:=
res
.
status
,
502
;
got
!=
want
{
t
.
Errorf
(
"status = %v; want %v"
,
got
,
want
)
}
}
// TestH2H1GracefulShutdown tests graceful shutdown.
func
TestH2H1GracefulShutdown
(
t
*
testing
.
T
)
{
st
:=
newServerTester
(
nil
,
t
,
noopHandler
)
...
...
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