mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-23 22:27:38 -05:00
proxy: Make headers when upstream is created; avoid potential nil ptr deref
This commit is contained in:
parent
280ba9db85
commit
1d47e590e5
1 changed files with 6 additions and 11 deletions
|
@ -41,6 +41,7 @@ func NewStaticUpstreams(c parse.Dispenser) ([]Upstream, error) {
|
|||
for c.Next() {
|
||||
upstream := &staticUpstream{
|
||||
from: "",
|
||||
proxyHeaders: make(http.Header),
|
||||
Hosts: nil,
|
||||
Policy: &Random{},
|
||||
FailTimeout: 10 * time.Second,
|
||||
|
@ -159,14 +160,8 @@ func parseBlock(c *parse.Dispenser, u *staticUpstream) error {
|
|||
if !c.Args(&header, &value) {
|
||||
return c.ArgErr()
|
||||
}
|
||||
if u.proxyHeaders == nil {
|
||||
u.proxyHeaders = make(http.Header)
|
||||
}
|
||||
u.proxyHeaders.Add(header, value)
|
||||
case "websocket":
|
||||
if u.proxyHeaders == nil {
|
||||
u.proxyHeaders = make(http.Header)
|
||||
}
|
||||
u.proxyHeaders.Add("Connection", "{>Connection}")
|
||||
u.proxyHeaders.Add("Upgrade", "{>Upgrade}")
|
||||
case "without":
|
||||
|
|
Loading…
Reference in a new issue