Fix payload iteration issue of FormBody; Log form body; ignore body for response of HEAD.

This commit is contained in:
Chunting Gu
2019-07-09 13:18:55 +08:00
parent 3309e7896a
commit b2cbc450b8
21 changed files with 364 additions and 165 deletions
+13 -13
View File
@@ -6,24 +6,12 @@
#include <utility>
#include <vector>
#include "boost/asio/buffer.hpp" // for const_buffer
#include "boost/filesystem/path.hpp"
#include "webcc/globals.h"
namespace webcc {
// -----------------------------------------------------------------------------
using Path = boost::filesystem::path;
using Payload = std::vector<boost::asio::const_buffer>;
// Read entire file into string.
bool ReadFile(const Path& path, std::string* output);
// -----------------------------------------------------------------------------
using Header = std::pair<std::string, std::string>;
class Headers {
@@ -211,10 +199,19 @@ public:
// API: CLIENT
void Prepare(Payload* payload);
// Get the payload size.
// Free the memory of the data.
void Free();
// Get the size of the whole payload.
// Used by the request to calculate content length.
std::size_t GetSize();
// Get the size of the data.
std::size_t GetDataSize();
// Dump to output stream for logging purpose.
void Dump(std::ostream& os, const std::string& prefix) const;
private:
// Generate headers from properties.
void SetHeaders();
@@ -226,6 +223,9 @@ private:
// the name will be "file1".
std::string name_;
// The path of the file to post.
Path path_;
// The original local file name.
// E.g., "baby.jpg".
std::string file_name_;