Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
aa42881e
Commit
aa42881e
authored
Oct 18, 2011
by
Andrew Gerrand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
http: add test for panic inside hijacked request
R=golang-dev, rsc, rsc CC=golang-dev
https://golang.org/cl/5283052
parent
b1fd528d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
1 deletion
+16
-1
serve_test.go
src/pkg/http/serve_test.go
+16
-1
No files found.
src/pkg/http/serve_test.go
View file @
aa42881e
...
...
@@ -864,6 +864,14 @@ func TestZeroLengthPostAndResponse(t *testing.T) {
}
func
TestHandlerPanic
(
t
*
testing
.
T
)
{
testHandlerPanic
(
t
,
false
)
}
func
TestHandlerPanicWithHijack
(
t
*
testing
.
T
)
{
testHandlerPanic
(
t
,
true
)
}
func
testHandlerPanic
(
t
*
testing
.
T
,
withHijack
bool
)
{
// Unlike the other tests that set the log output to ioutil.Discard
// to quiet the output, this test uses a pipe. The pipe serves three
// purposes:
...
...
@@ -884,7 +892,14 @@ func TestHandlerPanic(t *testing.T) {
log
.
SetOutput
(
pw
)
defer
log
.
SetOutput
(
os
.
Stderr
)
ts
:=
httptest
.
NewServer
(
HandlerFunc
(
func
(
ResponseWriter
,
*
Request
)
{
ts
:=
httptest
.
NewServer
(
HandlerFunc
(
func
(
w
ResponseWriter
,
r
*
Request
)
{
if
withHijack
{
rwc
,
_
,
err
:=
w
.
(
Hijacker
)
.
Hijack
()
if
err
!=
nil
{
t
.
Logf
(
"unexpected error: %v"
,
err
)
}
defer
rwc
.
Close
()
}
panic
(
"intentional death for testing"
)
}))
defer
ts
.
Close
()
...
...
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