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
e85ba0d4
Commit
e85ba0d4
authored
Nov 03, 2016
by
Tw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
proxy: make value is optional when removing a header
fix issue #1234 Signed-off-by:
Tw
<
tw19881113@gmail.com
>
parent
b89cbe18
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
2 deletions
+24
-2
caddyhttp/proxy/setup_test.go
caddyhttp/proxy/setup_test.go
+16
-0
caddyhttp/proxy/upstream.go
caddyhttp/proxy/upstream.go
+8
-2
No files found.
caddyhttp/proxy/setup_test.go
View file @
e85ba0d4
...
...
@@ -131,6 +131,22 @@ func TestSetup(t *testing.T) {
"http://localhost:8005/a--b"
:
{},
},
},
// test #12 test value is optional when remove upstream header
{
"proxy / localhost:1984 {
\n
header_upstream -server
\n
}"
,
false
,
map
[
string
]
struct
{}{
"http://localhost:1984"
:
{},
},
},
// test #13 test value is optional when remove downstream header
{
"proxy / localhost:1984 {
\n
header_downstream -server
\n
}"
,
false
,
map
[
string
]
struct
{}{
"http://localhost:1984"
:
{},
},
},
}
{
c
:=
caddy
.
NewTestController
(
"http"
,
test
.
input
)
err
:=
setup
(
c
)
...
...
caddyhttp/proxy/upstream.go
View file @
e85ba0d4
...
...
@@ -305,13 +305,19 @@ func parseBlock(c *caddyfile.Dispenser, u *staticUpstream) error {
case
"header_upstream"
:
var
header
,
value
string
if
!
c
.
Args
(
&
header
,
&
value
)
{
return
c
.
ArgErr
()
// When removing a header, the value can be optional.
if
!
strings
.
HasPrefix
(
header
,
"-"
)
{
return
c
.
ArgErr
()
}
}
u
.
upstreamHeaders
.
Add
(
header
,
value
)
case
"header_downstream"
:
var
header
,
value
string
if
!
c
.
Args
(
&
header
,
&
value
)
{
return
c
.
ArgErr
()
// When removing a header, the value can be optional.
if
!
strings
.
HasPrefix
(
header
,
"-"
)
{
return
c
.
ArgErr
()
}
}
u
.
downstreamHeaders
.
Add
(
header
,
value
)
case
"transparent"
:
...
...
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