fix: fix issue for multipart/form-data and cookie header (#4172)
* fix(multipart-formdata): fix type for data variable * fix(multipart-formdata): fix parameter filter for unsetted file * fix(multipart-formdata): add mime type for sending file * fix(multipart-formdata): add application/octet-stream by default mimetype * fix(multipart-formdata): remove content-type: multipart/form-data header * fix(multipart-formdata): remove cookie cookie header if not present * fix(multipart-formdata): fix content-type filter --------- Co-authored-by: Dmitry Mukovkin <d.mukovkin@cft.ru>
This commit is contained in:
@@ -20,7 +20,8 @@ enum FormDataValue {
|
||||
Text(String),
|
||||
File {
|
||||
filename: String,
|
||||
data: Vec<u8>
|
||||
data: Vec<u8>,
|
||||
mime: String
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,11 +113,12 @@ fn convert_bodydef_to_req_action(req: &RequestDef) -> Option<ReqBodyAction> {
|
||||
for entry in entries {
|
||||
form = match &entry.value {
|
||||
FormDataValue::Text(value) => form.text(entry.key.clone(), value.clone()),
|
||||
FormDataValue::File { filename, data } =>
|
||||
FormDataValue::File { filename, data, mime } =>
|
||||
form.part(
|
||||
entry.key.clone(),
|
||||
reqwest::multipart::Part::bytes(data.clone())
|
||||
.file_name(filename.clone())
|
||||
.mime_str(mime.as_str()).expect("Error while setting File enum")
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user