rob05c commented on a change in pull request #3647: Fix for missing port in 
redirect to https
URL: https://github.com/apache/trafficcontrol/pull/3647#discussion_r295378443
 
 

 ##########
 File path: traffic_monitor/srvhttp/srvhttp.go
 ##########
 @@ -186,7 +187,15 @@ func (s *Server) RunHTTPSRedirect(addr string, 
addrForRedirect string, readTimeo
 }
 
 func (s *Server) redirectTLS(w http.ResponseWriter, r *http.Request) {
-       host, _, _ := net.SplitHostPort(r.Host)
+       host, _, err := net.SplitHostPort(r.Host)
+       if err != nil {
+               if strings.Contains(err.Error(), "missing port in address") {
+                       host = r.Host
+               } else {
+                       w.WriteHeader(http.StatusInternalServerError)
+                       w.Write([]byte(`{"error": "marshalling: ` + err.Error() 
+ `"}`))
 
 Review comment:
   Yeah, this is writing the `500` code, but then it goes ahead and calls 
`http.Redirect` below. Is this supposed to have a `return` here?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to