Allow following redirects when passing a URL
Docker / build (push) Waiting to run Details

This commit is contained in:
Chris W 2024-01-15 14:35:56 -07:00
parent eff7cbeffe
commit 96021984e6
4 changed files with 12 additions and 1 deletions

3
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,3 @@
{
"crystal-lang.mainFile": "${workspaceRoot}/src/main.cr"
}

View File

@ -10,6 +10,9 @@ targets:
cli:
main: src/console.cr
crystalline:
main: src/main.cr
dependencies:
athena:
github: athena-framework/framework

View File

@ -38,7 +38,6 @@ module Paste69
raise ATH::Exceptions::BadRequest.new("Missing token")
end
if fd.has_key?("delete")
paste.delete
return ATH::Response.new("", status: 200)

View File

@ -88,6 +88,12 @@ module Paste69
headers = HTTP::Headers{ "Accept-Encoding" => "identity" }
res = HTTP::Client.get(url, headers: headers)
attempts = 1
while (location = res.headers["Location"]?) && attempts <= 3
res = HTTP::Client.get(location, headers: headers)
attempts += 1
end
if res.status.to_i >= 300
raise ATH::Exceptions::BadRequest.new("URL response was not OK")