Skip to content

Commit

Permalink
add HTTP PATCH and UPDATE methods in webserver
Browse files Browse the repository at this point in the history
Building REST api with libnavajo requires to support PATCH and UPDATE methods.

Signed-off-by: Julien Courtat <[email protected]>
  • Loading branch information
jcourtat committed Jul 27, 2017
1 parent d7c5cdf commit 9c95475
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
11 changes: 10 additions & 1 deletion include/libnavajo/HttpRequest.hh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,16 @@

//****************************************************************************

typedef enum { UNKNOWN_METHOD = 0, GET_METHOD = 1, POST_METHOD = 2, PUT_METHOD = 3, DELETE_METHOD = 4 } HttpRequestMethod;
typedef enum {
UNKNOWN_METHOD = 0,
GET_METHOD = 1,
POST_METHOD = 2,
PUT_METHOD = 3,
DELETE_METHOD = 4,
UPDATE_METHOD = 5,
PATCH_METHOD = 6,
} HttpRequestMethod;

typedef enum { GZIP, ZLIB, NONE } CompressionMode;
typedef struct
{
Expand Down
6 changes: 6 additions & 0 deletions src/WebServer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,12 @@ bool WebServer::accept_request(ClientSockData* client, bool authSSL)
else
if (strncmp(bufLine+j, "DELETE", 6) == 0)
{ requestMethod=DELETE_METHOD; isQueryStr=true; j+=7; }
else
if (strncmp(bufLine+j, "UPDATE", 6) == 0)
{ requestMethod=UPDATE_METHOD; isQueryStr=true; j+=7; }
else
if (strncmp(bufLine+j, "PATCH", 5) == 0)
{ requestMethod=PATCH_METHOD; isQueryStr=true; j+=6; }

if (isQueryStr)
{
Expand Down

0 comments on commit 9c95475

Please sign in to comment.