Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
caddy
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
caddy
Commits
696b46f0
Commit
696b46f0
authored
Jan 23, 2017
by
Matt Holt
Committed by
GitHub
Jan 23, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1356 from mholt/fix_hijack
proxy: Fixed #1352: invalid use of the HTTP hijacker
parents
e5ef285e
ae10122f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
3 deletions
+18
-3
caddyhttp/proxy/reverseproxy.go
caddyhttp/proxy/reverseproxy.go
+18
-3
No files found.
caddyhttp/proxy/reverseproxy.go
View file @
696b46f0
...
...
@@ -238,7 +238,7 @@ func (rp *ReverseProxy) ServeHTTP(rw http.ResponseWriter, outreq *http.Request,
panic
(
httpserver
.
NonHijackerError
{
Underlying
:
rw
})
}
conn
,
_
,
err
:=
hj
.
Hijack
()
conn
,
brw
,
err
:=
hj
.
Hijack
()
if
err
!=
nil
{
return
err
}
...
...
@@ -260,8 +260,23 @@ func (rp *ReverseProxy) ServeHTTP(rw http.ResponseWriter, outreq *http.Request,
}
defer
backendConn
.
Close
()
go
pooledIoCopy
(
backendConn
,
conn
)
// write tcp stream to backend
pooledIoCopy
(
conn
,
backendConn
)
// read tcp stream from backend
// Proxy backend -> frontend.
go
pooledIoCopy
(
conn
,
backendConn
)
// Proxy frontend -> backend.
//
// NOTE: Hijack() sometimes returns buffered up bytes in brw which
// would be lost if we didn't read them out manually below.
if
brw
!=
nil
{
if
n
:=
brw
.
Reader
.
Buffered
();
n
>
0
{
rbuf
,
err
:=
brw
.
Reader
.
Peek
(
n
)
if
err
!=
nil
{
return
err
}
backendConn
.
Write
(
rbuf
)
}
}
pooledIoCopy
(
backendConn
,
conn
)
}
else
{
copyHeader
(
rw
.
Header
(),
res
.
Header
)
...
...
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