When it's requested, verify length deferrer support in the datastore
This commit is contained in:
parent
326986cc65
commit
c6d5ad08c0
|
@ -261,7 +261,7 @@ func (handler *UnroutedHandler) PostFile(w http.ResponseWriter, r *http.Request)
|
||||||
} else {
|
} else {
|
||||||
uploadLengthHeader := r.Header.Get("Upload-Length")
|
uploadLengthHeader := r.Header.Get("Upload-Length")
|
||||||
uploadDeferLengthHeader := r.Header.Get("Upload-Defer-Length")
|
uploadDeferLengthHeader := r.Header.Get("Upload-Defer-Length")
|
||||||
size, sizeIsDeferred, err = validateNewUploadLengthHeaders(uploadLengthHeader, uploadDeferLengthHeader)
|
size, sizeIsDeferred, err = handler.validateNewUploadLengthHeaders(uploadLengthHeader, uploadDeferLengthHeader)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
handler.sendError(w, r, err)
|
handler.sendError(w, r, err)
|
||||||
return
|
return
|
||||||
|
@ -873,12 +873,14 @@ func (handler *UnroutedHandler) sizeOfUploads(ids []string) (size int64, err err
|
||||||
|
|
||||||
// Verify that the Upload-Length and Upload-Defer-Length headers are acceptable for creating a
|
// Verify that the Upload-Length and Upload-Defer-Length headers are acceptable for creating a
|
||||||
// new upload
|
// new upload
|
||||||
func validateNewUploadLengthHeaders(uploadLengthHeader string, uploadDeferLengthHeader string) (uploadLength int64, uploadLengthDeferred bool, err error) {
|
func (handler *UnroutedHandler) validateNewUploadLengthHeaders(uploadLengthHeader string, uploadDeferLengthHeader string) (uploadLength int64, uploadLengthDeferred bool, err error) {
|
||||||
haveBothLengthHeaders := uploadLengthHeader != "" && uploadDeferLengthHeader != ""
|
haveBothLengthHeaders := uploadLengthHeader != "" && uploadDeferLengthHeader != ""
|
||||||
haveInvalidDeferHeader := uploadDeferLengthHeader != "" && uploadDeferLengthHeader != UploadLengthDeferred
|
haveInvalidDeferHeader := uploadDeferLengthHeader != "" && uploadDeferLengthHeader != UploadLengthDeferred
|
||||||
lengthIsDeferred := uploadDeferLengthHeader == UploadLengthDeferred
|
lengthIsDeferred := uploadDeferLengthHeader == UploadLengthDeferred
|
||||||
|
|
||||||
if haveBothLengthHeaders {
|
if lengthIsDeferred && !handler.composer.UsesLengthDeferrer {
|
||||||
|
err = ErrNotImplemented
|
||||||
|
} else if haveBothLengthHeaders {
|
||||||
err = ErrUploadLengthAndUploadDeferLength
|
err = ErrUploadLengthAndUploadDeferLength
|
||||||
} else if haveInvalidDeferHeader {
|
} else if haveInvalidDeferHeader {
|
||||||
err = ErrInvalidUploadDeferLength
|
err = ErrInvalidUploadDeferLength
|
||||||
|
|
Loading…
Reference in New Issue