File tree Expand file tree Collapse file tree 1 file changed +4
-6
lines changed
routers/api/packages/swift Expand file tree Collapse file tree 1 file changed +4
-6
lines changed Original file line number Diff line number Diff line change @@ -292,21 +292,19 @@ func DownloadManifest(ctx *context.Context) {
292292
293293// formFileOptionalReadCloser returns (nil, nil) if the formKey is not present.
294294func formFileOptionalReadCloser (ctx * context.Context , formKey string ) (io.ReadCloser , error ) {
295- var file io.ReadCloser
296- multipartFile , _ , err := ctx .Req .FormFile (formKey ) // it calls ParseMultipartForm automatically
295+ multipartFile , _ , err := ctx .Req .FormFile (formKey )
297296 if err != nil && ! errors .Is (err , http .ErrMissingFile ) {
298297 return nil , err
299298 }
300299 if multipartFile != nil {
301300 return multipartFile , nil
302301 }
303302
304- _ = ctx .Req .ParseForm () // although ParseForm should have been called by FormFile->ParseMultipartForm, it's safe to call it again
305- if ! ctx . Req . Form . Has ( formKey ) {
303+ content : = ctx .Req .FormValue ( formKey )
304+ if content == "" {
306305 return nil , nil
307306 }
308- file = io .NopCloser (strings .NewReader (ctx .Req .FormValue (formKey )))
309- return file , nil
307+ return io .NopCloser (strings .NewReader (ctx .Req .FormValue (formKey ))), nil
310308}
311309
312310// UploadPackageFile refers to https://github.com/swiftlang/swift-package-manager/blob/main/Documentation/PackageRegistry/Registry.md#endpoint-6
You can’t perform that action at this time.
0 commit comments