diff --git a/examples/apt-archive/proxy.ss b/examples/apt-archive/proxy.ss index dec9e59b..d3469c8b 100644 --- a/examples/apt-archive/proxy.ss +++ b/examples/apt-archive/proxy.ss @@ -210,21 +210,21 @@ (http:configure-server 'http port (http:url-handler (match-define `( ,method ,original-path ,path) request) - (let retry ([path path] [n 0] [header header]) + (let retry ([rpath path] [n 0] [header header]) (if (= n max-retries) (begin (report "exceeded ~a retries for ~a\n" max-retries original-path) (http:respond conn 500 '() #vu8())) - (match-let* ([(,_ ,scheme ,host ,port ,resource) - (pregexp-match (re "(http|https)://([^/:]+)(?:[:]([0-9]+))?(.*)") path)] - [,target-file (path-combine archive resource)]) - (if (not (and (http:valid-path? resource) + (match-let* ([(,_ ,scheme ,host ,port ,path) + (pregexp-match (re "(http|https)://([^/:]+)(?:[:]([0-9]+))?(.*)") rpath)] + [,target-file (path-combine archive path)]) + (if (not (and (http:valid-path? path) (string-ci=? "GET" (symbol->string method)))) (http:respond conn 400 '() #vu8()) (match (try (get-cached! target-file method scheme host port path header)) [#t (http:respond-file conn 200 '() target-file)] [#f (http:respond conn 404 '() #vu8())] - [`(catch ,reason) (retry path (+ n 1) header)] + [`(catch ,reason) (retry rpath (+ n 1) header)] [,redirect (guard (string? redirect)) (retry redirect (+ n 1) (copy-header header '(host accept user-agent)))])))))