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
ae10122f
Commit
ae10122f
authored
Jan 17, 2017
by
Leonard Hecker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
proxy: Fixed #1352: invalid use of the HTTP hijacker
parent
8464020f
Changes
1
Hide 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 @
ae10122f
...
@@ -238,7 +238,7 @@ func (rp *ReverseProxy) ServeHTTP(rw http.ResponseWriter, outreq *http.Request,
...
@@ -238,7 +238,7 @@ func (rp *ReverseProxy) ServeHTTP(rw http.ResponseWriter, outreq *http.Request,
panic
(
httpserver
.
NonHijackerError
{
Underlying
:
rw
})
panic
(
httpserver
.
NonHijackerError
{
Underlying
:
rw
})
}
}
conn
,
_
,
err
:=
hj
.
Hijack
()
conn
,
brw
,
err
:=
hj
.
Hijack
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
@@ -260,8 +260,23 @@ func (rp *ReverseProxy) ServeHTTP(rw http.ResponseWriter, outreq *http.Request,
...
@@ -260,8 +260,23 @@ func (rp *ReverseProxy) ServeHTTP(rw http.ResponseWriter, outreq *http.Request,
}
}
defer
backendConn
.
Close
()
defer
backendConn
.
Close
()
go
pooledIoCopy
(
backendConn
,
conn
)
// write tcp stream to backend
// Proxy backend -> frontend.
pooledIoCopy
(
conn
,
backendConn
)
// read tcp stream from backend
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
{
}
else
{
copyHeader
(
rw
.
Header
(),
res
.
Header
)
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