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
df0915e3
Commit
df0915e3
authored
3 years ago
by
cnnrmnn
Browse files
Options
Downloads
Patches
Plain Diff
Check partial request support with Accept-Ranges
parent
b9b91775
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
+9
-10
9 additions, 10 deletions
Library/Homebrew/utils/curl.rb
with
9 additions
and
10 deletions
Library/Homebrew/utils/curl.rb
+
9
−
10
View file @
df0915e3
...
...
@@ -130,23 +130,22 @@ module Utils
destination
.
dirname
.
mkpath
if
try_partial
range_stdout
=
curl_output
(
"--location"
,
"--range"
,
"0-1"
,
"--dump-header"
,
"-"
,
"--write-out"
,
"%
\{
http_code}"
,
range_stdout
=
curl_output
(
"--location"
,
"--dump-header"
,
"-"
,
"--head"
,
*
args
,
**
options
).
stdout
headers
,
_
,
http_status
=
range_stdout
.
partition
(
"
\r\n\r\n
"
)
headers
=
parse_headers
(
range_stdout
.
split
(
"
\r\n\r\n
"
)
.
first
)
supports_partial_download
=
http_status
.
to_i
==
206
# Partial Content
if
supports_partial_download
&&
# Any value for `accept-ranges` other than none indicates that the server supports range requests.
# Its absence indicates no support.
supports_partial
=
headers
[
"accept-ranges"
]
&&
headers
[
"accept-ranges"
]
!=
"none"
if
supports_partial
&&
destination
.
exist?
&&
destination
.
size
==
%r{^.*Content-Range: bytes
\d
+-
\d
+/(
\d
+)
\r\n
.*$}m
.
match
(
headers
)
&
.
[
](
1
)
&
.
to_i
destination
.
size
==
headers
[
"content-length"
]
.
to_i
return
# We've already downloaded all the bytes
end
else
supports_partial_download
=
false
end
continue_at
=
if
destination
.
exist?
&&
supports_partial
_download
continue_at
=
if
destination
.
exist?
&&
supports_partial
"-"
else
0
...
...
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