Menu

[r2366]: / framework / trunk / cppcms / http_content_filter.h  Maximize  Restore  History

Download this file

158 lines (137 with data), 4.5 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
///////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2008-2015 Artyom Beilis (Tonkikh) <artyomtnk@yahoo.com>
//
// See accompanying file COPYING.TXT file for licensing details.
//
///////////////////////////////////////////////////////////////////////////////
#ifndef CPPCMS_HTTP_CONTENT_FILTER_H
#define CPPCMS_HTTP_CONTENT_FILTER_H
#include <cppcms/defs.h>
#include <cppcms/cppcms_error.h>
#include <booster/hold_ptr.h>
#include <booster/noncopyable.h>
#include <string>
namespace cppcms {
namespace impl {
class cached_settings;
}
namespace http {
class file;
class context;
///
/// Exceptions that is thrown to abort content upload progress indicating an error
///
class CPPCMS_API abort_upload : public cppcms_error {
public:
///
/// Abort upload progress, thrown from classes derived from basic_content_filter
/// to abort the upload progress. status_code is the HTTP error code returned, for example 413
/// requested entity is too large
///
abort_upload(int status_code);
virtual ~abort_upload() throw();
///
/// Get the code
///
int code() const;
private:
int code_;
};
///
/// Class that represent the limits on the input content sizes
///
class CPPCMS_API content_limits : public booster::noncopyable {
friend class request;
public:
/// \cond INTERNAL
content_limits(impl::cached_settings const &);
content_limits();
~content_limits();
/// \endcond
///
/// Get the size limit in bytes of any non multipart/form-data content
///
/// Note form fields without content-type would be limited by this
/// size even if the multipart_form_data_limit is much larger
///
long long content_length_limit() const;
///
/// Set the size limit of any non multipart/form-data content
///
/// Note form fields without content-type would be limited by this
/// size even if the multipart_form_data_limit is much larger
///
void content_length_limit(long long size);
///
/// Get the size limit of multipart/form-data content in bytes
///
/// Note form fields without content-type would be limited by content_length_limit
/// size even if the multipart_form_data_limit is much larger
///
long long multipart_form_data_limit() const;
///
/// Set the size limit of multipart/form-data content in bytes
///
/// Note form fields without content-type would be limited by content_length_limit
/// size even if the multipart_form_data_limit is much larger
///
void multipart_form_data_limit(long long size);
///
/// Get the maximal size of file that is still hold in memory rather than disk
///
size_t file_in_memory_limit() const;
///
/// Set the maximal size of file that is still hold in memory rather than disk
///
void file_in_memory_limit(size_t size);
///
/// Get a location of a temporary directory that files are uploaded to, if empty system default is used
///
std::string uploads_path() const;
///
/// Set a location of a temporary directory that files are uploaded to, if empty system default is used
///
void uploads_path(std::string const &path);
private:
long long content_length_limit_;
size_t file_in_memory_limit_;
long long multipart_form_data_limit_;
std::string uploads_path_;
struct _data;
booster::hold_ptr<_data> d;
};
class CPPCMS_API basic_content_filter {
basic_content_filter(basic_content_filter const &);
void operator=(basic_content_filter const &);
public:
basic_content_filter();
virtual ~basic_content_filter();
virtual void on_end_of_content();
virtual void on_error();
private:
struct _data;
booster::hold_ptr<_data> d;
};
class CPPCMS_API raw_content_filter : public basic_content_filter {
public:
virtual void on_data_chunk(void const *data,size_t data_size) = 0;
virtual ~raw_content_filter();
private:
struct _raw_data;
booster::hold_ptr<_raw_data> d;
};
class CPPCMS_API multipart_filter : public basic_content_filter {
public:
multipart_filter();
virtual ~multipart_filter();
virtual void on_new_file(http::file &input_file);
virtual void on_upload_progress(http::file &input_file);
virtual void on_data_ready(http::file &input_file);
private:
struct _mp_data;
booster::hold_ptr<_mp_data> d;
};
} // http
} // cppcms
#endif
MongoDB Logo MongoDB