Skip to content
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

Merged
merged 7 commits into from
Jul 28, 2017
Merged

replace wget with the implementation of go #25

merged 7 commits into from
Jul 28, 2017

Conversation

catatsuy
Copy link
Collaborator

refs #1

This commit works correctly. But an error is displayed when downloading LibreSSL.

Unsolicited response received on idle HTTP channel starting with "HTTP/1.0 408 Request Timeout\r\nDate: Sun, 16 Jul 2017 15:04:06 GMT\r\nServer: OpenBSD httpd\r\nConnection: close\r\nCo
ntent-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 typ
e=\"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>

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 use os.Chdir in the program. If you want to remove os.Chdir, we needs to remove tar.

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.

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())
Copy link
Owner

@cubicdaiya cubicdaiya Jul 17, 2017

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.

Copy link
Collaborator Author

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.

@cubicdaiya
Copy link
Owner

cubicdaiya commented Jul 17, 2017

I suggest that you make nginx-build to be able to switch wget or net/http by cli-option such as -use-wget for workaround.

$ nginx-build -d work # use net/http
$ nginx-build -d work --use-wget # use wget

Or it might be good that wget is used only when -verbose is given.

@catatsuy
Copy link
Collaborator Author

I do not think that you want to use wget because you want to download the source code only.

The source code of this product is complicated. It is enough to just provide a way to use net/http.

the default timeout of wget
@cubicdaiya
Copy link
Owner

This commit works correctly. But an error is displayed when downloading LibreSSL.

Unsolicited response received on idle HTTP channel starting with "HTTP/1.0 408 Request Timeout\r\nDate: Sun, 16 Jul 2017 15:04:06 GMT\r\nServer: OpenBSD httpd\r\nConnection: close\r\nCo
ntent-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 typ
e=\"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>

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 {
Copy link
Owner

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
Copy link
Owner

@cubicdaiya cubicdaiya Jul 20, 2017

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.

@catatsuy
Copy link
Collaborator Author

@cubicdaiya

  • rename function name and constanize in download.go
  • add an error in README.md (in the chapter of LibreSSL)
  • remove wget from the chapter of Requirements

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>
```
Copy link
Owner

@cubicdaiya cubicdaiya Jul 22, 2017

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
Copy link
Owner

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?

@catatsuy
Copy link
Collaborator Author

  • change constant name
  • simplified the README.md

@cubicdaiya cubicdaiya merged commit 82ac3fa into cubicdaiya:master Jul 28, 2017
@cubicdaiya
Copy link
Owner

Merged. Thanks.

@catatsuy catatsuy deleted the feature/reduce_dependence_wget branch July 28, 2017 10:03
@catatsuy
Copy link
Collaborator Author

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants