-
Notifications
You must be signed in to change notification settings - Fork 253
Open
Description
Description
The filename
magic parameter sometimes isn't removed from the underlying request, which make some requests fail, e.g. when using signed URLs to GCS bucket.
Details
Based on the code, I believe all the "magic" parameters should be removed before making a request.
This is not the case in case of an URL to tar.gz
directory, like this:
https://storage.googleapis.com/bucket/v1.0.0/binary_darwin_amd64.tar.gz
and configuration:
getterCli := &getter.Client{
Ctx: ctx,
Src: url, // url with `filename` magic param
Dst: tmpDestPath,
Pwd: pwd,
Mode: getter.ClientModeAny,
}
I tracked the code execution, and it falls in the if which changes the mode:
Line 217 in a2ebce9
mode = ClientModeFile |
if decompressor != nil {
// ...
mode = ClientModeFile
}
Which is why the filename
param is not removed, as the next if
is skipped, which actually removes the filename
param.
Lines 230 to 249 in a2ebce9
if mode == ClientModeAny { | |
// Ask the getter which client mode to use | |
mode, err = g.ClientMode(u) | |
if err != nil { | |
return err | |
} | |
// Destination is the base name of the URL path in "any" mode when | |
// a file source is detected. | |
if mode == ClientModeFile { | |
filename := filepath.Base(u.Path) | |
// Determine if we have a custom file name | |
if v := q.Get("filename"); v != "" { | |
// Delete the query parameter if we have it. | |
q.Del("filename") | |
u.RawQuery = q.Encode() | |
filename = v | |
} |
Fix incoming
I fixed it locally and will prepare a pull request soon. Hope you'll like it!
Metadata
Metadata
Assignees
Labels
No labels