Skip to content

Commit

Permalink
Upload-Limit in HEAD responses
Browse files Browse the repository at this point in the history
  • Loading branch information
Acconut committed Nov 2, 2024
1 parent a4287f3 commit a8bfbac
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/handler/head_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ func TestHead(t *testing.T) {
"Upload-Draft-Interop-Version": interopVersion,
"Upload-Offset": "5",
"Upload-Length": "10",
"Upload-Limit": "min-size=0,max-size=10",
}, false, interopVersion),
}).Run(handler, t)
})
Expand Down Expand Up @@ -211,6 +212,7 @@ func TestHead(t *testing.T) {
"Upload-Draft-Interop-Version": interopVersion,
"Upload-Offset": "10",
"Upload-Length": "10",
"Upload-Limit": "min-size=0,max-size=10",
}, true, interopVersion),
}).Run(handler, t)
})
Expand All @@ -231,6 +233,7 @@ func TestHead(t *testing.T) {
handler, _ := NewHandler(Config{
StoreComposer: composer,
EnableExperimentalProtocol: true,
MaxSize: 400,
})

(&httpTest{
Expand All @@ -244,6 +247,7 @@ func TestHead(t *testing.T) {
"Upload-Draft-Interop-Version": interopVersion,
"Upload-Offset": "5",
"Upload-Length": "",
"Upload-Limit": "min-size=0,max-size=400",
}, false, interopVersion),
}).Run(handler, t)
})
Expand Down
2 changes: 2 additions & 0 deletions pkg/handler/unrouted_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,8 @@ func (handler *UnroutedHandler) HeadFile(w http.ResponseWriter, r *http.Request)
resp.Header["Upload-Length"] = strconv.FormatInt(info.Size, 10)
}

resp.Header["Upload-Limit"] = handler.getIETFDraftUploadLimits(info)

// Draft -01 and -02 require a 204 No Content response. Version -03 allows 200 OK as well,
// but we stick to 204 to not make the logic less complex.
resp.StatusCode = http.StatusNoContent
Expand Down

0 comments on commit a8bfbac

Please sign in to comment.