Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
packer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kristopher Ruzic
packer
Commits
d98de209
Commit
d98de209
authored
Jun 16, 2015
by
Vasiliy Tolstov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fallback to not ranged request if server lacks HEAD
Signed-off-by:
Vasiliy Tolstov
<
v.tolstov@selfip.ru
>
parent
382fa01e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
7 deletions
+13
-7
common/download.go
common/download.go
+13
-7
No files found.
common/download.go
View file @
d98de209
...
...
@@ -215,18 +215,23 @@ func (d *HTTPDownloader) Download(dst *os.File, src *url.URL) error {
}
resp
,
err
:=
httpClient
.
Do
(
req
)
if
err
!=
nil
{
return
err
if
err
!=
nil
||
resp
.
StatusCode
!=
200
{
req
.
Method
=
"GET"
resp
,
err
=
httpClient
.
Do
(
req
)
if
err
!=
nil
{
return
err
}
}
req
.
Method
=
"GET"
if
resp
.
StatusCode
!=
200
{
log
.
Printf
(
"Non-200 status code: %d. Getting error body."
,
resp
.
StatusCode
)
resp
,
err
:=
httpClient
.
Do
(
req
)
if
err
!=
nil
{
return
err
if
req
.
Method
!=
"GET"
{
req
.
Method
=
"GET"
resp
,
err
=
httpClient
.
Do
(
req
)
if
err
!=
nil
{
return
err
}
}
errorBody
:=
new
(
bytes
.
Buffer
)
io
.
Copy
(
errorBody
,
resp
.
Body
)
...
...
@@ -234,6 +239,7 @@ func (d *HTTPDownloader) Download(dst *os.File, src *url.URL) error {
resp
.
StatusCode
,
errorBody
.
String
())
}
req
.
Method
=
"GET"
d
.
progress
=
0
if
resp
.
Header
.
Get
(
"Accept-Ranges"
)
==
"bytes"
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment