"context"
"fmt"
"net/http"
+ "net/url"
"time"
_ "unsafe"
logFormat = "%v %v%v > %v local %v %v %v"
)
- url := chosenBack.To
+ path := chosenBack.To
if chosenBack.PathAdd() {
- url += r.RequestURI
+ if s, e := url.PathUnescape(r.URL.Path); e != nil {
+ logger.Warn(`W:`, fmt.Sprintf(logFormat, r.RemoteAddr, chosenBack.route.config.Addr, routePath, chosenBack.Name, "BLOCK", e, time.Since(opT)))
+ return ErrDealReqUri
+ } else {
+ path += s
+ }
}
- if !pfile.New(url, 0, true).IsExist() {
+ if !pfile.New(path, 0, true).IsExist() {
return ErrReqDoFail
}
logger.Debug(`T:`, fmt.Sprintf(logFormat, r.RemoteAddr, chosenBack.route.config.Addr, routePath, chosenBack.Name, r.Method, r.RequestURI, time.Since(opT)))
- http.ServeFile(w, r.WithContext(ctx), url)
+ http.ServeFile(w, r.WithContext(ctx), path)
return nil
}