let parser = MultipartParser(boundary: "12345")
var parts: [MultipartPart] = []
var headers: [String: String] = [:]
var body: String = ""
parser.onHeader = { (field, value) in
headers[field] = value
}
parser.onBody = { new in
body += new.readString(length: new.readableBytes)!
}
parser.onPartComplete = {
let part = MultipartPart(headers: headers, body: body)
headers = [:]
body = ""
parts.append(part)
}
for chunk in data.chunked(by: i) {
try parser.execute(.init(chunk))
}
print(parts)
Fixes #355