Skip to content

Commit

Permalink
WIP rename differently
Browse files Browse the repository at this point in the history
  • Loading branch information
owaddell-beckman committed Jun 7, 2024
1 parent 79867fe commit ec5ad6e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions examples/apt-archive/proxy.ss
Original file line number Diff line number Diff line change
Expand Up @@ -210,21 +210,21 @@
(http:configure-server 'http port
(http:url-handler
(match-define `(<request> ,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)))])))))
Expand Down

0 comments on commit ec5ad6e

Please sign in to comment.