File tree 1 file changed +4
-6
lines changed
routers/api/packages/swift 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) {
292
292
293
293
// formFileOptionalReadCloser returns (nil, nil) if the formKey is not present.
294
294
func 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 )
297
296
if err != nil && ! errors .Is (err , http .ErrMissingFile ) {
298
297
return nil , err
299
298
}
300
299
if multipartFile != nil {
301
300
return multipartFile , nil
302
301
}
303
302
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 == "" {
306
305
return nil , nil
307
306
}
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
310
308
}
311
309
312
310
// 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