Avoid labelling requests on non-standard ports as malformed.
This commit is contained in:
parent
0bbdb6482e
commit
c8a8de95ae
|
@ -702,6 +702,7 @@ func (r *GenRouter) SuspiciousRequest(req *http.Request, prepend string) {
|
|||
func (r *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||
// Redirect www. requests to the right place
|
||||
if req.Host == "www." + common.Site.Host {
|
||||
// TODO: Abstract the redirect logic?
|
||||
w.Header().Set("Connection", "close")
|
||||
var s string
|
||||
if common.Site.EnableSsl {
|
||||
|
@ -716,7 +717,8 @@ func (r *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
|||
}
|
||||
|
||||
// Deflect malformed requests
|
||||
if len(req.URL.Path) == 0 || req.URL.Path[0] != '/' || req.Host != common.Site.Host {
|
||||
shost := strings.Split(req.Host,":")
|
||||
if len(req.URL.Path) == 0 || req.URL.Path[0] != '/' || shost[0] != common.Site.Host || len(shost) > 2 {
|
||||
w.WriteHeader(200) // 400
|
||||
w.Write([]byte(""))
|
||||
r.DumpRequest(req,"Malformed Request")
|
||||
|
|
|
@ -481,6 +481,7 @@ func (r *GenRouter) SuspiciousRequest(req *http.Request, prepend string) {
|
|||
func (r *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||
// Redirect www. requests to the right place
|
||||
if req.Host == "www." + common.Site.Host {
|
||||
// TODO: Abstract the redirect logic?
|
||||
w.Header().Set("Connection", "close")
|
||||
var s string
|
||||
if common.Site.EnableSsl {
|
||||
|
@ -495,7 +496,8 @@ func (r *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
|||
}
|
||||
|
||||
// Deflect malformed requests
|
||||
if len(req.URL.Path) == 0 || req.URL.Path[0] != '/' || req.Host != common.Site.Host {
|
||||
shost := strings.Split(req.Host,":")
|
||||
if len(req.URL.Path) == 0 || req.URL.Path[0] != '/' || shost[0] != common.Site.Host || len(shost) > 2 {
|
||||
w.WriteHeader(200) // 400
|
||||
w.Write([]byte(""))
|
||||
r.DumpRequest(req,"Malformed Request")
|
||||
|
|
Loading…
Reference in New Issue