mirror of
https://gitee.com/IrisVega/frp.git
synced 2024-11-01 22:31:29 +08:00
improve not found response (#3121)
This commit is contained in:
parent
6ecc97c857
commit
6a71d71e58
@ -48,7 +48,6 @@ linters:
|
|||||||
- unconvert
|
- unconvert
|
||||||
- unparam
|
- unparam
|
||||||
- gci
|
- gci
|
||||||
- bodyclose
|
|
||||||
- gosec
|
- gosec
|
||||||
- asciicheck
|
- asciicheck
|
||||||
- prealloc
|
- prealloc
|
||||||
|
@ -251,7 +251,7 @@ func (rp *HTTPReverseProxy) connectHandler(rw http.ResponseWriter, req *http.Req
|
|||||||
|
|
||||||
remote, err := rp.CreateConnection(domain, url, routeByHTTPUser, remoteAddr)
|
remote, err := rp.CreateConnection(domain, url, routeByHTTPUser, remoteAddr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(rw, "Failed", http.StatusBadRequest)
|
_ = notFoundResponse().Write(client)
|
||||||
client.Close()
|
client.Close()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -72,14 +72,16 @@ func notFoundResponse() *http.Response {
|
|||||||
header.Set("server", "frp/"+version.Full())
|
header.Set("server", "frp/"+version.Full())
|
||||||
header.Set("Content-Type", "text/html")
|
header.Set("Content-Type", "text/html")
|
||||||
|
|
||||||
|
content := getNotFoundPageContent()
|
||||||
res := &http.Response{
|
res := &http.Response{
|
||||||
Status: "Not Found",
|
Status: "Not Found",
|
||||||
StatusCode: 404,
|
StatusCode: 404,
|
||||||
Proto: "HTTP/1.0",
|
Proto: "HTTP/1.1",
|
||||||
ProtoMajor: 1,
|
ProtoMajor: 1,
|
||||||
ProtoMinor: 0,
|
ProtoMinor: 1,
|
||||||
Header: header,
|
Header: header,
|
||||||
Body: io.NopCloser(bytes.NewReader(getNotFoundPageContent())),
|
Body: io.NopCloser(bytes.NewReader(content)),
|
||||||
|
ContentLength: int64(len(content)),
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user