NAS: Reply HTML page to conntest

This commit is contained in:
mkwcat
2023-12-19 00:18:45 -05:00
parent 602aac4d59
commit e130fdc60f
2 changed files with 26 additions and 3 deletions

24
nas/conntest.go Normal file
View File

@@ -0,0 +1,24 @@
package nas
import (
"net/http"
"strconv"
)
func handleConnectionTest(w http.ResponseWriter) {
response := "\n"
response += ` <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">` + "\n"
response += ` <html>` + "\n"
response += ` <head>` + "\n"
response += ` <title>HTML Page</title>` + "\n"
response += ` </head>` + "\n"
response += ` <body bgcolor="#FFFFFF">` + "\n"
response += ` This is test.html page` + "\n"
response += ` </body>` + "\n"
response += ` </html>` + "\n"
w.Header().Set("Content-Type", "text/html")
w.Header().Set("Content-Length", strconv.Itoa(len(response)))
w.WriteHeader(200)
w.Write([]byte(response))
}

View File

@@ -87,10 +87,9 @@ func handleRequest(w http.ResponseWriter, r *http.Request) {
return
}
// Reply 200 to conntest
// Handle conntest server
if strings.HasPrefix(r.Host, "conntest.") {
// Respond with a 200 status code
replyHTTPError(w, 200, "ok")
handleConnectionTest(w)
return
}