HttpReader: allow empty filename.

GitOrigin-RevId: ad65a2e603d4628c6a4d29d26300a113303d0c27
This commit is contained in:
levlam 2018-10-14 19:08:15 +03:00
parent f5ea140bc2
commit 1d32712f6a
2 changed files with 4 additions and 1 deletions

View File

@ -290,6 +290,7 @@ Result<bool> HttpReader::parse_multipart_form_data() {
file_field_name_.clear();
field_content_type_ = "application/octet-stream";
file_name_.clear();
has_file_name_ = false;
CHECK(temp_file_.empty());
temp_file_name_.clear();
@ -349,6 +350,7 @@ Result<bool> HttpReader::parse_multipart_form_data() {
field_name_ = value;
} else if (key == "filename") {
file_name_ = value.str();
has_file_name_ = true;
} else {
// ignore unknown parts of header
}
@ -368,7 +370,7 @@ Result<bool> HttpReader::parse_multipart_form_data() {
return Status::Error(400, "Bad Request: field name in multipart/form-data not found");
}
if (!file_name_.empty()) {
if (has_file_name_) {
// file
if (query_->files_.size() == max_files_) {
return Status::Error(413, "Request Entity Too Large: too much files attached");

View File

@ -80,6 +80,7 @@ class HttpReader {
string file_field_name_;
string field_content_type_;
string file_name_;
bool has_file_name_ = false;
FileFd temp_file_;
string temp_file_name_;
int64 file_size_;