From c4fa4d25b415001b9536ceb425ff661e6c12bd6f Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Sun, 29 May 2011 21:39:51 -0700 Subject: [PATCH] Protocol change: remove some upload restrictions that were only for App Engine. Now effective SHOULDs. Not changing the spec yet, though. Need to fix App Engine python impl. --- lib/go/camli/blobserver/handlers/upload.go | 28 +++++++++++++++------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/lib/go/camli/blobserver/handlers/upload.go b/lib/go/camli/blobserver/handlers/upload.go index 92d780332..548c90adb 100644 --- a/lib/go/camli/blobserver/handlers/upload.go +++ b/lib/go/camli/blobserver/handlers/upload.go @@ -30,6 +30,14 @@ import ( "strings" ) +// We used to require that multipart sections had a content type and +// filename to make App Engine happy. Now that App Engine supports up +// to 32 MB requests and programatic blob writing we can just do this +// ourselves and stop making compromises in the spec. Also because +// the JavaScript FormData spec (http://www.w3.org/TR/XMLHttpRequest2/) +// doesn't let you set those. +const oldAppEngineHappySpec = false + func CreateUploadHandler(storage blobserver.BlobReceiveConfiger) func(http.ResponseWriter, *http.Request) { return func(conn http.ResponseWriter, req *http.Request) { handleMultiPartUpload(conn, req, storage) @@ -85,16 +93,18 @@ func handleMultiPartUpload(conn http.ResponseWriter, req *http.Request, blobRece continue } - _, hasContentType := mimePart.Header["Content-Type"] - if !hasContentType { - addError(fmt.Sprintf("Expected Content-Type header for blobref %s; see spec", ref)) - continue - } + if oldAppEngineHappySpec { + _, hasContentType := mimePart.Header["Content-Type"] + if !hasContentType { + addError(fmt.Sprintf("Expected Content-Type header for blobref %s; see spec", ref)) + continue + } - _, hasFileName := params["filename"] - if !hasFileName { - addError(fmt.Sprintf("Expected 'filename' Content-Disposition parameter for blobref %s; see spec", ref)) - continue + _, hasFileName := params["filename"] + if !hasFileName { + addError(fmt.Sprintf("Expected 'filename' Content-Disposition parameter for blobref %s; see spec", ref)) + continue + } } blobGot, err := blobReceiver.ReceiveBlob(ref, mimePart)