-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
replace wget with the implementation of go #25
replace wget with the implementation of go #25
Conversation
This commit works correctly. But an error is displayed when downloading LibreSSL. cf: golang/go#12855 cf: golang/go#19895 cf: golang/go#2057 Even if an error is displayed, execution will not stop so there is no problem. Because we use `os.Chdir` in the program, the location where the file is saved is the same as when `wget` is used. If you want to remove `os.Chdir`, we needs to remove `tar`.
download.go
Outdated
if command.VerboseEnabled { | ||
return command.Run(args) | ||
func downloadForBuilder(b *builder.Builder) error { | ||
res, err := http.Get(b.DownloadURL()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As http.Get()
uses http.DefaultClient
, timeout is not set. We should set timeout for http client by default. FYI, the default timeout of wget
is 900 seconds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created a http.Client
instance which set timeout every time.
I suggest that you make
Or it might be good that |
I do not think that you want to use The source code of this product is complicated. It is enough to just provide a way to use |
the default timeout of wget
As this behavior is very confused, I suggest it is referred in README.md. |
download.go
Outdated
args := []string{"wget", url} | ||
if command.VerboseEnabled { | ||
return command.Run(args) | ||
func downloadForBuilder(b *builder.Builder) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this function name should be renamed. download(b *builder.Builder)
is good.
download.go
Outdated
return command.Run(args) | ||
func downloadForBuilder(b *builder.Builder) error { | ||
c := &http.Client{ | ||
Timeout: time.Duration(900) * time.Second, // the default timeout of wget |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not use magick number. Use const. And you don't need to refer to wget.
|
README.md
Outdated
|
||
``` | ||
Unsolicited response received on idle HTTP channel starting with "HTTP/1.0 408 Request Timeout\r\nDate: Sat, 22 Jul 2017 06:55:35 GMT\r\nServer: OpenBSD httpd\r\nConnection: close\r\nContent-Type: text/html\r\nContent-Length: 439\r\n\r\n<!DOCTYPE html>\n<html>\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>\n<title>408 Request Timeout</title>\n<style type=\"text/css\"><!--\nbody { background-color: white; color: black; font-family: 'Comic Sans MS', 'Chalkboard SE', 'Comic Neue', sans-serif; }\nhr { border: 0; border-bottom: 1px dashed; }\n\n--></style>\n</head>\n<body>\n<h1>408 Request Timeout</h1>\n<hr>\n<address>OpenBSD httpd</address>\n</body>\n</html>\n"; err=<nil> | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I want to keep README.md simple, remove actual error message and link to this PR.
download.go
Outdated
|
||
"github.com/cubicdaiya/nginx-build/builder" | ||
"github.com/cubicdaiya/nginx-build/command" | ||
"github.com/cubicdaiya/nginx-build/util" | ||
) | ||
|
||
const DefaultTimeout = time.Duration(900) * time.Second |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is better to specify what timeout. How about DefaultDownloadTimeout?
|
Merged. Thanks. |
thanks! |
refs #1
This commit works correctly. But an error is displayed when downloading LibreSSL.
cf: golang/go#12855
cf: golang/go#19895
cf: golang/go#2057
Even if an error is displayed, execution will not stop so there is no problem.
The location where the file is saved is the same as when
wget
is used because we useos.Chdir
in the program. If you want to removeos.Chdir
, we needs to removetar
.Why do I want to replace wget with the implementation of go
wget
is not preinstalled by default on Mac.I often use Docker with minimal configuration Linux distribution. In such a distribution,
wget
may not be installed.