aboutsummaryrefslogtreecommitdiffstats
path: root/parser.h
diff options
context:
space:
mode:
Diffstat (limited to 'parser.h')
-rw-r--r--parser.h16
1 files changed, 9 insertions, 7 deletions
diff --git a/parser.h b/parser.h
index b5375a1..af1d6c3 100644
--- a/parser.h
+++ b/parser.h
@@ -1,6 +1,10 @@
+#pragma once
+
#include <string>
#include <unordered_map>
+#include "http_request.h"
+
namespace flask
{
template <typename Handler>
@@ -96,14 +100,12 @@ namespace flask
bool feed(const char* buffer, int length)
{
- std::cerr << "<|" << std::string(buffer, buffer+length) << "|>" << std::endl;
int nparsed = http_parser_execute(this, &settings_, buffer, length);
return nparsed == length;
}
bool done()
{
- std::cerr << "(done)" << std::endl;
int nparsed = http_parser_execute(this, &settings_, nullptr, 0);
return nparsed == 0;
}
@@ -120,14 +122,14 @@ namespace flask
void process_message()
{
- //std::cout << "URL: "<< url << std::endl;
- //for(auto& kv : headers)
- //{
- //std::cout << kv.first << ": " << kv.second << std::endl;
- //}
handler_->handle();
}
+ request to_request()
+ {
+ return request{std::move(url), std::move(headers), std::move(body)};
+ }
+
std::string url;
int header_building_state = 0;
std::string header_field;