-
Notifications
You must be signed in to change notification settings - Fork 0
Configurable Timeouts for HTTP Requests #93
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -6,6 +6,7 @@ import ( | |||||||
| "os" | ||||||||
|
|
||||||||
| "github.com/Snider/Borg/pkg/compress" | ||||||||
| "github.com/Snider/Borg/pkg/httpclient" | ||||||||
| "github.com/Snider/Borg/pkg/tim" | ||||||||
| "github.com/Snider/Borg/pkg/trix" | ||||||||
| "github.com/Snider/Borg/pkg/ui" | ||||||||
|
|
@@ -44,6 +45,13 @@ func NewCollectGithubRepoCmd() *cobra.Command { | |||||||
| return fmt.Errorf("invalid compression: %s (must be 'none', 'gz', or 'xz')", compression) | ||||||||
| } | ||||||||
|
|
||||||||
| totalTimeout, _ := cmd.Flags().GetDuration("timeout") | ||||||||
| connectTimeout, _ := cmd.Flags().GetDuration("connect-timeout") | ||||||||
| tlsTimeout, _ := cmd.Flags().GetDuration("tls-timeout") | ||||||||
| headerTimeout, _ := cmd.Flags().GetDuration("header-timeout") | ||||||||
|
|
||||||||
| _ = httpclient.NewClient(totalTimeout, connectTimeout, tlsTimeout, headerTimeout) | ||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The To fix this, the
Suggested change
|
||||||||
|
|
||||||||
| prompter := ui.NewNonInteractivePrompter(ui.GetVCSQuote) | ||||||||
| prompter.Start() | ||||||||
| defer prompter.Stop() | ||||||||
|
|
||||||||
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.
The errors returned from
cmd.Flags().GetDuration()are being ignored. If a user provides a malformed duration string (e.g.,"--timeout=10xyz"), the flag will use its default value and return an error, but the user won't be notified of their invalid input. These errors should be handled to provide better feedback.This same issue is present in other files where these flags are parsed, such as
cmd/collect_github_repo.go,cmd/collect_github_repos.go,cmd/collect_pwa.go, andcmd/collect_website.go.