You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
func upload(_ req: Request) throws {
let file = try req.content.decode(Upload.self)
// doing some other stuff
}
struct Upload: Content {
let file : File
}
Using Backtrace I found the line where the fatalError is raised :
Fatal error: file Vapor/MultipartParser.swift, line 186
The error is raised on the handleHeadersComplete function.
Me and the iOS developer spent some hours digging into the MultipartParser decoding strategy and we found the headers decoding is made using three different functions:
handleHeaderField (Vapor/MultipartParser.swift, line 158)
handleHeaderValue (Vapor/MultipartParser.swift, line 170)
handleHeadersComplete (Vapor/MultipartParser.swift, line 186) where we got the fatal error.
Simplifying a lot the handleHeaderField function read the header name, handleHeaderValue the value for that header and handleHeadersComplete declares the header is complete.
Passing an empty mime type, the parser fail to decode the "Content-Type" header raising a fatalError, stopping the execution and causing a server crash.
The text was updated successfully, but these errors were encountered:
Describe the bug
Server crashes on a multipart/form-data request with an empty mimeType.
To Reproduce
Steps to reproduce the behavior:
Content
conform struct on the server.Expected behavior
The request throw a decoding error avoiding server crashes and providing a readable error message.
Environment
Additional context
This is how the AlamoFire request is sent (See MultipartFormData):
and this is how I decode it :
Using Backtrace I found the line where the fatalError is raised :
The error is raised on the
handleHeadersComplete
function.Me and the iOS developer spent some hours digging into the MultipartParser decoding strategy and we found the headers decoding is made using three different functions:
handleHeaderField
(Vapor/MultipartParser.swift, line 158)handleHeaderValue
(Vapor/MultipartParser.swift, line 170)handleHeadersComplete
(Vapor/MultipartParser.swift, line 186) where we got the fatal error.Simplifying a lot the
handleHeaderField
function read the header name,handleHeaderValue
the value for that header andhandleHeadersComplete
declares the header is complete.Passing an empty mime type, the parser fail to decode the "Content-Type" header raising a fatalError, stopping the execution and causing a server crash.
The text was updated successfully, but these errors were encountered: