stephb9959
2023-04-19 14:03:31 -07:00
parent 7ad4de4960
commit 8b21ef16a1
50 changed files with 5523 additions and 4992 deletions

View File

@@ -4,29 +4,26 @@
#pragma once
#include <string>
#include "Poco/Net/PartHandler.h"
#include "Poco/Net/MessageHeader.h"
#include "Poco/CountingStream.h"
#include "Poco/Net/MessageHeader.h"
#include "Poco/Net/PartHandler.h"
#include "Poco/NullStream.h"
#include "Poco/StreamCopier.h"
#include <string>
namespace OpenWifi {
class RESTAPI_PartHandler: public Poco::Net::PartHandler {
class RESTAPI_PartHandler : public Poco::Net::PartHandler {
public:
RESTAPI_PartHandler():
_length(0)
{
}
RESTAPI_PartHandler() : _length(0) {}
inline void handlePart(const Poco::Net::MessageHeader& header, std::istream& stream) override
{
inline void handlePart(const Poco::Net::MessageHeader &header,
std::istream &stream) override {
_type = header.get("Content-Type", "(unspecified)");
if (header.has("Content-Disposition"))
{
if (header.has("Content-Disposition")) {
std::string disp;
Poco::Net::NameValueCollection params;
Poco::Net::MessageHeader::splitParameters(header["Content-Disposition"], disp, params);
Poco::Net::MessageHeader::splitParameters(header["Content-Disposition"], disp,
params);
_name = params.get("name", "(unnamed)");
_fileName = params.get("filename", "(unnamed)");
}
@@ -37,25 +34,13 @@ namespace OpenWifi {
_length = (int)istr.chars();
}
[[nodiscard]] inline int length() const
{
return _length;
}
[[nodiscard]] inline int length() const { return _length; }
[[nodiscard]] inline const std::string& name() const
{
return _name;
}
[[nodiscard]] inline const std::string &name() const { return _name; }
[[nodiscard]] inline const std::string& fileName() const
{
return _fileName;
}
[[nodiscard]] inline const std::string &fileName() const { return _fileName; }
[[nodiscard]] inline const std::string& contentType() const
{
return _type;
}
[[nodiscard]] inline const std::string &contentType() const { return _type; }
private:
int _length;
@@ -63,4 +48,4 @@ namespace OpenWifi {
std::string _name;
std::string _fileName;
};
}
} // namespace OpenWifi