crow
crow copied to clipboard
PATCH method doesn't work
Isn't that code supposed to work?
#include "crow.h"
#include <cassert>
#include <iostream>
#include <string>
#include <functional>
#include <sstream>
using namespace std;
using namespace placeholders;
int main()
{
crow::SimpleApp app;
CROW_ROUTE(app, "/patch")
.methods("PATCH"_method)
([](const crow::request& req) {
return "test";
});
auto port = 18080;
app.port(port).multithreaded().run();
}
It gives "invalid method" error on CROW_ROUTE. "PATCH" for operator""_method is not defined in common.h. I tried adding it in analogy with "POST" (add in , but it still doesn't work: error 404 on PATCH-request.
(2016-09-22 07:03:48) [INFO ] Request: 127.0.0.1:35958 0x23bbf00 HTTP/1.1 invalid /patch
Looks like it can't parse PATCH here
} else if (parser->index == 1 && parser->method == HTTP_POST) {
if (ch == 'R') {
parser->method = HTTP_PROPFIND; /* or HTTP_PROPPATCH */
} else if (ch == 'U') {
parser->method = HTTP_PUT; /* or HTTP_PURGE */
} else if (ch == 'A') {
parser->method = HTTP_PATCH;
} else {
CROW_SET_ERRNO(HPE_INVALID_METHOD);
goto error;
}
}
But I still don't really understand what's going on here.
Any Progress here?
Still doesn't work? Example from tests looks same as above one (https://github.com/ipkn/crow/blob/master/tests/unittest.cpp#L328).