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
497ebb9c
Commit
497ebb9c
authored
Apr 06, 2016
by
Wolfgang Johannes Kohnen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle host names case insensitively.
RFC 3986 3.2.2: The host subcomponent is case-insensitive.
parent
e4e773c9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
0 deletions
+11
-0
caddy/parse/parsing.go
caddy/parse/parsing.go
+4
-0
caddy/parse/parsing_test.go
caddy/parse/parsing_test.go
+3
-0
server/server.go
server/server.go
+4
-0
No files found.
caddy/parse/parsing.go
View file @
497ebb9c
...
...
@@ -104,6 +104,7 @@ func (p *parser) addresses() error {
if
err
!=
nil
{
return
err
}
p
.
block
.
Addresses
=
append
(
p
.
block
.
Addresses
,
addr
)
}
...
...
@@ -329,6 +330,9 @@ func standardAddress(str string) (address, error) {
}
}
// "The host subcomponent is case-insensitive." (RFC 3986)
host
=
strings
.
ToLower
(
host
)
// see if we can set port based off scheme
if
port
==
""
{
if
scheme
==
"http"
{
...
...
caddy/parse/parsing_test.go
View file @
497ebb9c
...
...
@@ -13,7 +13,9 @@ func TestStandardAddress(t *testing.T) {
shouldErr
bool
}{
{
`localhost`
,
""
,
"localhost"
,
""
,
false
},
{
`LOCALHOST`
,
""
,
"localhost"
,
""
,
false
},
{
`localhost:1234`
,
""
,
"localhost"
,
"1234"
,
false
},
{
`LOCALHOST:1234`
,
""
,
"localhost"
,
"1234"
,
false
},
{
`localhost:`
,
""
,
"localhost"
,
""
,
false
},
{
`0.0.0.0`
,
""
,
"0.0.0.0"
,
""
,
false
},
{
`127.0.0.1:1234`
,
""
,
"127.0.0.1"
,
"1234"
,
false
},
...
...
@@ -35,6 +37,7 @@ func TestStandardAddress(t *testing.T) {
{
`https://127.0.0.1`
,
"https"
,
"127.0.0.1"
,
"443"
,
false
},
{
`http://[::1]`
,
"http"
,
"::1"
,
"80"
,
false
},
{
`http://localhost:1234`
,
"http"
,
"localhost"
,
"1234"
,
false
},
{
`http://LOCALHOST:1234`
,
"http"
,
"localhost"
,
"1234"
,
false
},
{
`https://127.0.0.1:1234`
,
"https"
,
"127.0.0.1"
,
"1234"
,
false
},
{
`http://[::1]:1234`
,
"http"
,
"::1"
,
"1234"
,
false
},
{
``
,
""
,
""
,
""
,
false
},
...
...
server/server.go
View file @
497ebb9c
...
...
@@ -13,6 +13,7 @@ import (
"net/http"
"os"
"runtime"
"strings"
"sync"
"time"
)
...
...
@@ -301,6 +302,9 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
host
=
r
.
Host
// oh well
}
// "The host subcomponent is case-insensitive." (RFC 3986)
host
=
strings
.
ToLower
(
host
)
// Try the host as given, or try falling back to 0.0.0.0 (wildcard)
if
_
,
ok
:=
s
.
vhosts
[
host
];
!
ok
{
if
_
,
ok2
:=
s
.
vhosts
[
"0.0.0.0"
];
ok2
{
...
...
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