forgot to add httprequestbody code

This commit is contained in:
Mike Nolan 2024-12-13 01:17:22 -06:00
parent 0e2d0a2d7e
commit fc43f006a9
3 changed files with 36 additions and 0 deletions

View File

@ -9,6 +9,7 @@ namespace Tesses::Framework::Http
public:
virtual void HandleHeaders(HttpDictionary& dict);
virtual void Write(Tesses::Framework::Streams::Stream* strm)=0;
virtual ~HttpRequestBody();
};
class StreamHttpRequestBody : public HttpRequestBody {

View File

@ -10,6 +10,7 @@
#include "TextStreams/StreamReader.hpp"
#include "TextStreams/StreamWriter.hpp"
#include "Threading/Thread.hpp"
#include "Threading/Mutex.hpp"
#include "Filesystem/LocalFS.hpp"
#include "Filesystem/SubdirFilesystem.hpp"
#include "Filesystem/NullFilesystem.hpp"

View File

@ -15,6 +15,40 @@ using BufferedStream = Tesses::Framework::Streams::BufferedStream;
using HttpStream = Tesses::Framework::Http::HttpStream;
namespace Tesses::Framework::Http
{
void HttpRequestBody::HandleHeaders(HttpDictionary& dict)
{
}
HttpRequestBody::~HttpRequestBody()
{
}
StreamHttpRequestBody::StreamHttpRequestBody(Stream* strm, bool owns, std::string mimeType)
{
this->strm = strm;
this->owns = owns;
this->mimeType = mimeType;
}
void StreamHttpRequestBody::HandleHeaders(HttpDictionary& dict)
{
dict.AddValue("Content-Type",this->mimeType);
auto len = this->strm->GetLength();
if(len > -1) dict.AddValue("Content-Length",std::to_string(len));
}
void StreamHttpRequestBody::Write(Tesses::Framework::Streams::Stream* strm)
{
strm->CopyTo(this->strm);
}
StreamHttpRequestBody::~StreamHttpRequestBody()
{
if(this->owns)
delete this->strm;
}
HttpRequest::HttpRequest()
{
this->body=nullptr;