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

Fix "Content-Dispositon" header #210

Merged
merged 1 commit into from
May 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions handlers/objects.go
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,11 @@
attributes = params.header.Attributes()
)

if paramIsPositive(params.download) {
dis = "attachment"

Check warning on line 592 in handlers/objects.go

View check run for this annotation

Codecov / codecov/patch

handlers/objects.go#L591-L592

Added lines #L591 - L592 were not covered by tests
}
ctx.Response().Header().Set("Content-Disposition", dis)

Check warning on line 594 in handlers/objects.go

View check run for this annotation

Codecov / codecov/patch

handlers/objects.go#L594

Added line #L594 was not covered by tests

if len(attributes) > 0 {
for _, attr := range attributes {
key := attr.Key()
Expand All @@ -598,10 +603,8 @@

switch key {
case object.AttributeFileName:
if paramIsPositive(params.download) {
dis = "attachment"
}
ctx.Response().Header().Set("Content-Disposition", dis+"; filename="+path.Base(val))
// Add FileName to Content-Disposition
ctx.Response().Header().Set("Content-Disposition", ctx.Response().Header().Get("Content-Disposition")+"; filename="+path.Base(val))

Check warning on line 607 in handlers/objects.go

View check run for this annotation

Codecov / codecov/patch

handlers/objects.go#L607

Added line #L607 was not covered by tests
if params.useJSON {
attrJSON[key] = val
} else {
Expand Down
Loading