Browse Source

Fix path parsing

DarthSim 6 năm trước cách đây
mục cha
commit
d4ca9af5be
2 tập tin đã thay đổi với 4 bổ sung4 xóa
  1. 1 1
      processing_options.go
  2. 3 3
      server.go

+ 1 - 1
processing_options.go

@@ -624,7 +624,7 @@ func parsePathSimple(parts []string, acceptHeader string) (string, processingOpt
 }
 
 func parsePath(ctx context.Context, rctx *fasthttp.RequestCtx) (context.Context, error) {
-	path := string(rctx.RequestURI())
+	path := string(rctx.Path())
 	parts := strings.Split(strings.TrimPrefix(path, "/"), "/")
 
 	var acceptHeader string

+ 3 - 3
server.go

@@ -22,7 +22,7 @@ var (
 
 	authHeaderMust []byte
 
-	healthRequestURI = []byte("/health")
+	healthPath = []byte("/health")
 
 	serverMutex mutex
 
@@ -139,7 +139,7 @@ func serveHTTP(rctx *fasthttp.RequestCtx) {
 		}
 	}()
 
-	log.Printf("[%s] %s: %s\n", reqID, rctx.Method(), rctx.RequestURI())
+	log.Printf("[%s] %s: %s\n", reqID, rctx.Method(), rctx.Path())
 
 	writeCORS(rctx)
 
@@ -159,7 +159,7 @@ func serveHTTP(rctx *fasthttp.RequestCtx) {
 	serverMutex.Lock()
 	defer serverMutex.Unock()
 
-	if bytes.Equal(rctx.RequestURI(), healthRequestURI) {
+	if bytes.Equal(rctx.Path(), healthPath) {
 		rctx.SetStatusCode(200)
 		rctx.SetBodyString("imgproxy is running")
 		return