parse content-type form header

This commit is contained in:
jaina heartles 2022-12-03 06:36:54 -08:00
parent e27d0064ee
commit 6cfd035883

View file

@ -113,6 +113,7 @@ const MultipartFormField = struct {
pub const FormFile = struct {
data: []const u8,
filename: []const u8,
content_type: []const u8,
};
pub fn MultipartForm(comptime ReaderType: type) type {
@ -170,9 +171,12 @@ fn Deserializer(comptime Result: type) type {
const data = try util.deepClone(alloc, val.value);
errdefer util.deepFree(alloc, data);
const filename = try util.deepClone(alloc, val.filename orelse "(untitled)");
errdefer util.deepFree(alloc, filename);
const content_type = try util.deepClone(alloc, val.content_type orelse "application/octet-stream");
return FormFile{
.data = data,
.filename = filename,
.content_type = content_type,
};
}
});