* Multipart form content length calculation

* HTMLForm test
This commit is contained in:
Rangel Reale
2013-12-04 18:19:20 -02:00
parent 5edb90c48e
commit 0d2a839f79
12 changed files with 164 additions and 5 deletions

View File

@@ -83,7 +83,11 @@ public:
const std::string& filename() const;
/// Returns the filename portion of the path.
std::streamsize getContentLength() const;
/// Returns the file size.
private:
std::string _path;
std::string _filename;
Poco::FileInputStream _istr;
};

View File

@@ -173,7 +173,14 @@ public:
/// Otherwise, if the request's HTTP version is HTTP/1.1:
/// - the request's persistent connection state is left unchanged
/// - the content transfer encoding is set to chunked
std::streamsize calculateContentLength();
/// Calculate the content length for the form.
/// May be UNKNOWN_CONTENT_LENGTH if not possible
/// to calculate
void write(std::ostream& ostr, const std::string& boundary);
/// Writes the form data to the given output stream,
/// using the specified encoding.
@@ -203,6 +210,7 @@ public:
static const std::string ENCODING_URL; /// "application/x-www-form-urlencoded"
static const std::string ENCODING_MULTIPART; /// "multipart/form-data"
static const int UNKNOWN_CONTENT_LENGTH;
protected:
void readUrl(std::istream& istr);
void readMultipart(std::istream& istr, PartHandler& handler);

View File

@@ -77,9 +77,15 @@ public:
/// Returns a MessageHeader containing additional header
/// fields for the part.
virtual std::streamsize getContentLength() const;
/// Returns the content length for this part
/// which may be UNKNOWN_CONTENT_LENGTH if
/// not available.
virtual ~PartSource();
/// Destroys the PartSource.
static const int UNKNOWN_CONTENT_LENGTH;
protected:
PartSource();
/// Creates the PartSource, using

View File

@@ -75,6 +75,9 @@ public:
const std::string& filename() const;
/// Returns the filename portion of the path.
std::streamsize getContentLength() const;
/// Returns the string size.
private:
std::istringstream _istr;
std::string _filename;