Add basic proxy parser
This commit is contained in:
+17
-2
@@ -28,6 +28,7 @@
|
||||
#include "f2/function2.hpp"
|
||||
|
||||
#include "BloomFilter.h"
|
||||
#include "ProxyParser.h"
|
||||
|
||||
namespace uWS {
|
||||
|
||||
@@ -237,9 +238,9 @@ private:
|
||||
public:
|
||||
|
||||
/* We do this to prolong the validity of parsed headers by keeping only the fallback buffer alive */
|
||||
std::string &&salvageFallbackBuffer() {
|
||||
/*std::string &&salvageFallbackBuffer() {
|
||||
return std::move(fallback);
|
||||
}
|
||||
}*/
|
||||
|
||||
void *consumePostPadded(char *data, int length, void *user, fu2::unique_function<void *(void *, HttpRequest *)> &&requestHandler, fu2::unique_function<void *(void *, std::string_view, bool)> &&dataHandler, fu2::unique_function<void *(void *)> &&errorHandler) {
|
||||
|
||||
@@ -275,6 +276,9 @@ public:
|
||||
fallback.reserve(fallback.length() + maxCopyDistance + std::max<int>(MINIMUM_HTTP_POST_PADDING, sizeof(std::string)));
|
||||
fallback.append(data, maxCopyDistance);
|
||||
|
||||
// parse proxy here
|
||||
|
||||
|
||||
// break here on break
|
||||
std::pair<int, void *> consumed = fenceAndConsumePostPadded<true>(fallback.data(), (int) fallback.length(), user, &req, requestHandler, dataHandler);
|
||||
if (consumed.second != user) {
|
||||
@@ -318,6 +322,17 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
// parse proxy here
|
||||
/* Parse proxy header */
|
||||
ProxyParser pp;
|
||||
auto [done, offset] = pp.parse({data, length});
|
||||
|
||||
if (!done) {
|
||||
|
||||
} else {
|
||||
printf("Proxy parser is done\n");
|
||||
}
|
||||
|
||||
std::pair<int, void *> consumed = fenceAndConsumePostPadded<false>(data, length, user, &req, requestHandler, dataHandler);
|
||||
if (consumed.second != user) {
|
||||
return consumed.second;
|
||||
|
||||
Reference in New Issue
Block a user