Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
brew
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to JiHu GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
KMSCAKKSCFKA AKFACAMADCAS
brew
Commits
c42bcf73
Unverified
Commit
c42bcf73
authored
4 years ago
by
Dustin Rodrigues
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #8076 from dtrodrigues/301-redirect
curl: alert on 301 redirect
parents
e7006bee
c4d11374
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Library/Homebrew/utils/curl.rb
+12
-7
12 additions, 7 deletions
Library/Homebrew/utils/curl.rb
with
12 additions
and
7 deletions
Library/Homebrew/utils/curl.rb
+
12
−
7
View file @
c42bcf73
...
...
@@ -127,6 +127,8 @@ def curl_check_http_content(url, user_agents: [:default], check_content: false,
return
"The URL
#{
url
}
is not reachable"
end
return
"
#{
url
}
permanently redirects to
#{
details
[
:permanent_redirect
]
}
"
if
url
!=
details
[
:permanent_redirect
]
unless
http_status_ok?
(
details
[
:status
])
return
"The URL
#{
url
}
is not reachable (HTTP status code
#{
details
[
:status
]
}
)"
end
...
...
@@ -203,20 +205,23 @@ def curl_http_content_headers_and_checksum(url, hash_needed: false, user_agent:
status_code
=
headers
[
%r{HTTP/.* (
\d
+)}
,
1
]
location
=
headers
[
/^Location:\s*(.*)$/i
,
1
]
final_url
=
location
.
chomp
if
location
permanent_redirect
=
location
.
chomp
if
status_code
==
"301"
end
output_hash
=
Digest
::
SHA256
.
file
(
file
.
path
)
if
hash_needed
final_url
||=
url
permanent_redirect
||=
url
{
url:
url
,
final_url:
final_url
,
status:
status_code
,
etag:
headers
[
%r{ETag: ([wW]/)?"(([^"]|
\\
")*)"}
,
2
],
content_length:
headers
[
/Content-Length: (\d+)/
,
1
],
file_hash:
output_hash
,
file:
output
,
url:
url
,
final_url:
final_url
,
permanent_redirect:
permanent_redirect
,
status:
status_code
,
etag:
headers
[
%r{ETag: ([wW]/)?"(([^"]|
\\
")*)"}
,
2
],
content_length:
headers
[
/Content-Length: (\d+)/
,
1
],
file_hash:
output_hash
,
file:
output
,
}
ensure
file
.
unlink
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment