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
e5d33e73
Commit
e5d33e73
authored
Oct 10, 2016
by
Tw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
header: implement http.Hijacker for responseWriterWrapper
fix issue #1173 Signed-off-by:
Tw
<
tw19881113@gmail.com
>
parent
9ced4b17
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
1 deletion
+13
-1
caddyhttp/header/header.go
caddyhttp/header/header.go
+12
-0
caddyhttp/proxy/reverseproxy.go
caddyhttp/proxy/reverseproxy.go
+1
-1
No files found.
caddyhttp/header/header.go
View file @
e5d33e73
...
@@ -4,6 +4,9 @@
...
@@ -4,6 +4,9 @@
package
header
package
header
import
(
import
(
"bufio"
"errors"
"net"
"net/http"
"net/http"
"strings"
"strings"
...
@@ -113,3 +116,12 @@ func (rww *responseWriterWrapper) setHeader(key, value string) {
...
@@ -113,3 +116,12 @@ func (rww *responseWriterWrapper) setHeader(key, value string) {
h
.
Set
(
key
,
value
)
h
.
Set
(
key
,
value
)
})
})
}
}
// Hijack implements http.Hijacker. It simply wraps the underlying
// ResponseWriter's Hijack method if there is one, or returns an error.
func
(
rww
*
responseWriterWrapper
)
Hijack
()
(
net
.
Conn
,
*
bufio
.
ReadWriter
,
error
)
{
if
hj
,
ok
:=
rww
.
w
.
(
http
.
Hijacker
);
ok
{
return
hj
.
Hijack
()
}
return
nil
,
nil
,
errors
.
New
(
"not a Hijacker"
)
}
caddyhttp/proxy/reverseproxy.go
View file @
e5d33e73
...
@@ -189,7 +189,7 @@ func (rp *ReverseProxy) ServeHTTP(rw http.ResponseWriter, outreq *http.Request,
...
@@ -189,7 +189,7 @@ func (rp *ReverseProxy) ServeHTTP(rw http.ResponseWriter, outreq *http.Request,
res
.
Body
.
Close
()
res
.
Body
.
Close
()
hj
,
ok
:=
rw
.
(
http
.
Hijacker
)
hj
,
ok
:=
rw
.
(
http
.
Hijacker
)
if
!
ok
{
if
!
ok
{
return
nil
panic
(
"not a hijacker"
)
}
}
conn
,
_
,
err
:=
hj
.
Hijack
()
conn
,
_
,
err
:=
hj
.
Hijack
()
...
...
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