ipkn / crow

Crow is very fast and easy to use C++ micro web framework (inspired by Python Flask)
BSD 3-Clause "New" or "Revised" License
7.49k stars 890 forks source link

PATCH method doesn't work #163

Open Rasie1 opened 8 years ago

Rasie1 commented 8 years ago

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.

tommy87 commented 4 years ago

Any Progress here?

mrozigor commented 4 years ago

Still doesn't work? Example from tests looks same as above one (https://github.com/ipkn/crow/blob/master/tests/unittest.cpp#L328).