Browse Source

virtual host names are now case-insensitive

Alan Shreve 12 years ago
parent
commit
bf7a36f03e
2 changed files with 5 additions and 1 deletions
  1. 2 1
      src/ngrok/server/http.go
  2. 3 0
      src/ngrok/server/tunnel.go

+ 2 - 1
src/ngrok/server/http.go

@@ -5,6 +5,7 @@ import (
 	"net"
 	"ngrok/conn"
 	"ngrok/log"
+	"strings"
 )
 
 const (
@@ -68,7 +69,7 @@ func httpHandler(tcpConn net.Conn) {
 	}
 
 	// read out the Host header from the request
-	host := req.Host
+	host := strings.ToLower(req.Host)
 	conn.Debug("Found hostname %s in request", host)
 
 	// multiplex to find the right backend host

+ 3 - 0
src/ngrok/server/tunnel.go

@@ -124,6 +124,9 @@ func newTunnel(m *msg.RegMsg, ctl *Control) (t *Tunnel) {
 			t.url = fmt.Sprintf("http://%s.%s", t.regMsg.Subdomain, vhost)
 		}
 
+		vhost = strings.ToLower(vhost)
+		t.url = strings.ToLower(t.url)
+
 		if t.url != "" {
 			if err := tunnels.Register(t.url, t); err != nil {
 				failReg(err)