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
56ec7b98
Commit
56ec7b98
authored
May 30, 2015
by
Austin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
websocket directive, upgrade comparison
parent
2d6ff406
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
8 deletions
+19
-8
middleware/proxy/reverseproxy.go
middleware/proxy/reverseproxy.go
+2
-2
middleware/proxy/upstream.go
middleware/proxy/upstream.go
+17
-6
No files found.
middleware/proxy/reverseproxy.go
View file @
56ec7b98
...
...
@@ -16,7 +16,7 @@ import (
"time"
)
const
HTTPSwitchProtocols
=
101
const
HTTPSwitch
ing
Protocols
=
101
// onExitFlushLoop is a callback set by tests to detect the state of the
// flushLoop() goroutine.
...
...
@@ -155,7 +155,7 @@ func (p *ReverseProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request, extr
copyHeader
(
rw
.
Header
(),
res
.
Header
)
if
res
.
StatusCode
==
HTTPSwitch
Protocols
{
if
res
.
StatusCode
==
HTTPSwitch
ingProtocols
&&
outreq
.
Header
.
Get
(
"Upgrade"
)
==
"websocket"
{
hj
,
ok
:=
rw
.
(
http
.
Hijacker
)
if
!
ok
{
return
nil
...
...
middleware/proxy/upstream.go
View file @
56ec7b98
...
...
@@ -12,7 +12,10 @@ import (
"github.com/mholt/caddy/config/parse"
)
var
supportedPolicies
map
[
string
]
func
()
Policy
=
make
(
map
[
string
]
func
()
Policy
)
var
(
supportedPolicies
map
[
string
]
func
()
Policy
=
make
(
map
[
string
]
func
()
Policy
)
proxyHeaders
http
.
Header
)
type
staticUpstream
struct
{
from
string
...
...
@@ -40,7 +43,7 @@ func NewStaticUpstreams(c parse.Dispenser) ([]Upstream, error) {
FailTimeout
:
10
*
time
.
Second
,
MaxFails
:
1
,
}
var
proxyHeaders
http
.
Header
if
!
c
.
Args
(
&
upstream
.
from
)
{
return
upstreams
,
c
.
ArgErr
()
}
...
...
@@ -97,10 +100,10 @@ func NewStaticUpstreams(c parse.Dispenser) ([]Upstream, error) {
if
!
c
.
Args
(
&
header
,
&
value
)
{
return
upstreams
,
c
.
ArgErr
()
}
if
proxyHeaders
==
nil
{
proxyHeaders
=
make
(
map
[
string
][]
string
)
}
proxyHeaders
.
Add
(
header
,
value
)
addProxyHeader
(
header
,
value
)
case
"websocket"
:
addProxyHeader
(
"Connection"
,
"{>Connection}"
)
addProxyHeader
(
"Upgrade"
,
"{>Upgrade}"
)
}
}
...
...
@@ -150,6 +153,14 @@ func RegisterPolicy(name string, policy func() Policy) {
supportedPolicies
[
name
]
=
policy
}
// AddProxyHeader adds a proxy header.
func
addProxyHeader
(
header
,
value
string
)
{
if
proxyHeaders
==
nil
{
proxyHeaders
=
make
(
map
[
string
][]
string
)
}
proxyHeaders
.
Add
(
header
,
value
)
}
func
(
u
*
staticUpstream
)
From
()
string
{
return
u
.
from
}
...
...
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