Skip to content

Commit

Permalink
feat: Show original URL in HTTP progress bars
Browse files Browse the repository at this point in the history
  • Loading branch information
twpayne committed Jan 17, 2025
1 parent 6cae2f1 commit 3176ad1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions internal/chezmoi/sourcestate.go
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,7 @@ TARGET:

// ReadOptions are options to SourceState.Read.
type ReadOptions struct {
ReadHTTPResponse func(*http.Response) ([]byte, error)
ReadHTTPResponse func(string, *http.Response) ([]byte, error)
RefreshExternals RefreshExternals
TimeNow func() time.Time
}
Expand Down Expand Up @@ -1634,7 +1634,7 @@ func (s *SourceState) getExternalDataRaw(
if options == nil || options.ReadHTTPResponse == nil {
data, err = io.ReadAll(resp.Body)
} else {
data, err = options.ReadHTTPResponse(resp)
data, err = options.ReadHTTPResponse(urlStr, resp)
}
resp.Body.Close()
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions internal/cmd/readhttpresponse.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func (m httpSpinnerModel) View() string {
return "[" + m.spinner.View() + "] " + m.url
}

func (c *Config) readHTTPResponse(resp *http.Response) ([]byte, error) {
func (c *Config) readHTTPResponse(url string, resp *http.Response) ([]byte, error) {
switch {
case c.noTTY || !c.Progress.Value(c.progressAutoFunc):
return io.ReadAll(resp.Body)
Expand All @@ -123,7 +123,7 @@ func (c *Config) readHTTPResponse(resp *http.Response) ([]byte, error) {
httpProgress.ShowPercentage = false

model := httpProgressModel{
url: resp.Request.URL.String(),
url: url,
contentLength: int(resp.ContentLength),
progress: httpProgress,
}
Expand Down

0 comments on commit 3176ad1

Please sign in to comment.