|
|
@ -135,26 +135,29 @@ private:
|
|
|
|
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class FormPart;
|
|
|
|
|
|
|
|
using FormPartPtr = std::shared_ptr<FormPart>;
|
|
|
|
|
|
|
|
|
|
|
|
// A part of the multipart form data.
|
|
|
|
// A part of the multipart form data.
|
|
|
|
class FormPart {
|
|
|
|
class FormPart {
|
|
|
|
public:
|
|
|
|
public:
|
|
|
|
FormPart() = default;
|
|
|
|
FormPart() = default;
|
|
|
|
|
|
|
|
|
|
|
|
// Construct a file part.
|
|
|
|
FormPart(const FormPart&) = delete;
|
|
|
|
// The file name will be extracted from path.
|
|
|
|
FormPart& operator=(const FormPart&) = delete;
|
|
|
|
// The media type, if not provided, will be inferred from file extension.
|
|
|
|
|
|
|
|
FormPart(const std::string& name, const Path& path,
|
|
|
|
|
|
|
|
const std::string& media_type = "");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Construct a non-file part.
|
|
|
|
// Construct a non-file part.
|
|
|
|
// The data will be moved, no file name is needed.
|
|
|
|
// The data will be moved, no file name is needed.
|
|
|
|
// The media type is optional. If the data is a JSON string, you can specify
|
|
|
|
// The media type is optional. If the data is a JSON string, you can specify
|
|
|
|
// media type as "application/json".
|
|
|
|
// media type as "application/json".
|
|
|
|
FormPart(const std::string& name, std::string&& data,
|
|
|
|
static FormPartPtr New(const std::string& name, std::string&& data,
|
|
|
|
const std::string& media_type = "");
|
|
|
|
const std::string& media_type = "");
|
|
|
|
|
|
|
|
|
|
|
|
FormPart(const FormPart&) = delete;
|
|
|
|
// Construct a file part.
|
|
|
|
FormPart& operator=(const FormPart&) = delete;
|
|
|
|
// The file name will be extracted from path.
|
|
|
|
|
|
|
|
// The media type, if not provided, will be inferred from file extension.
|
|
|
|
|
|
|
|
static FormPartPtr NewFile(const std::string& name, const Path& path,
|
|
|
|
|
|
|
|
const std::string& media_type = "");
|
|
|
|
|
|
|
|
|
|
|
|
// API: SERVER
|
|
|
|
// API: SERVER
|
|
|
|
const std::string& name() const {
|
|
|
|
const std::string& name() const {
|
|
|
@ -243,8 +246,6 @@ private:
|
|
|
|
std::string data_;
|
|
|
|
std::string data_;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
using FormPartPtr = std::shared_ptr<FormPart>;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace webcc
|
|
|
|
} // namespace webcc
|
|
|
|
|
|
|
|
|
|
|
|
#endif // WEBCC_COMMON_H_
|
|
|
|
#endif // WEBCC_COMMON_H_
|
|
|
|