Browse Source

Fixed compilation issue is multipart-parser

Added consistent API for check if it is file or form-data
master
Artyom Beilis 8 years ago
parent
commit
dae0be48c1
5 changed files with 12 additions and 5 deletions
  1. +4
    -0
      cppcms/http_file.h
  2. +0
    -2
      private/multipart_parser.h
  3. +1
    -1
      src/cgi_api.cpp
  4. +6
    -1
      src/http_file.cpp
  5. +1
    -1
      src/http_request.cpp

+ 4
- 0
cppcms/http_file.h View File

@@ -46,6 +46,10 @@ namespace http {
///
std::string mime() const;
///
/// Returns true if content type defined
///
bool has_mime() const;
///
/// Get the filename as it was sent by the browser.
///
std::string filename() const;


+ 0
- 2
private/multipart_parser.h View File

@@ -140,7 +140,6 @@ namespace cppcms {
break;
case expecting_separator_boundary:
{
content_in_ = true;
std::streambuf *out=file_->write_data().rdbuf();
char const *this_boundary = boundary_.c_str();
size_t boundary_size = boundary_.size();
@@ -172,7 +171,6 @@ namespace cppcms {
file_->data().seekg(0);
files_.push_back(file_);
file_.reset(new http::file());
content_in_ = false;
file_->set_temporary_directory(temp_dir_);
if(memory_limit_ != -1) {
file_->set_memory_limit(memory_limit_);


+ 1
- 1
src/cgi_api.cpp View File

@@ -369,7 +369,7 @@ void connection::on_some_multipart_read(booster::system::error_code const &e,siz
multipart_parser::files_type files = multipart_parser_->get_files();
long long allowed=service().cached_settings().security.content_length_limit*1024;
for(unsigned i=0;i<files.size();i++) {
if(files[i]->mime().empty() && files[i]->size() > allowed) {
if(!files[i]->has_mime() && files[i]->size() > allowed) {
BOOSTER_NOTICE("cppcms") << "multipart/form-data non-file entry size too big " <<
files[i]->size()
<< " REMOTE_ADDR = `" << getenv("REMOTE_ADDR")


+ 6
- 1
src/http_file.cpp View File

@@ -32,6 +32,12 @@ std::string file::mime() const
return mime_;
}

bool file::has_mime() const
{
return !mime_.empty();
}


std::string file::filename() const
{
return filename_;
@@ -159,7 +165,6 @@ void file::move_to_file()
saved_in_file_ = 1;
}


void file::add_bytes_to_size(size_t n)
{
d->size += n;


+ 1
- 1
src/http_request.cpp View File

@@ -156,7 +156,7 @@ namespace {
void request::set_post_data(std::vector<booster::shared_ptr<file> > const &multipart)
{
for(unsigned i=0;i<multipart.size();i++) {
if(multipart[i]->mime().empty()) {
if(!multipart[i]->has_mime()) {
post_.insert(std::make_pair(multipart[i]->name(),read_file(multipart[i]->data())));
}
else {


Loading…
Cancel
Save