Skip to content

fix: add timeout to HTTP client in GetURLBody#768

Open
mihir-dixit2k27 wants to merge 1 commit into
uyuni-project:mainfrom
mihir-dixit2k27:fix/http-download-timeout
Open

fix: add timeout to HTTP client in GetURLBody#768
mihir-dixit2k27 wants to merge 1 commit into
uyuni-project:mainfrom
mihir-dixit2k27:fix/http-download-timeout

Conversation

@mihir-dixit2k27
Copy link
Copy Markdown

http.Get in GetURLBody uses http.DefaultClient which has no
timeout. If the server is unresponsive, the process hangs indefinitely.

Fixed by using a local http.Client{Timeout: time.Minute} instead,
same as what shared/api/api.go already does.

The existing GetURLBody function used the package-level http.Get which
has no timeout configured. If a remote server hangs or is slow to
respond, the download would block indefinitely with no way to recover
short of killing the process.

Switched to a local http.Client with a one-minute timeout, which is
the same value already used by the API client in shared/api/api.go.

Signed-off-by: Mihir Dixit <dixitmihir1@gmail.com>
@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant