Skip to content

Commit 25ea317

Browse files
committed
support for purge method (not bulk)
nodejs has (in C) a method whitelist
1 parent 2e2e048 commit 25ea317

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

src/core/http.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#define LONGEST_REQMETHOD 6
2222
#define REQUEST_HTTPADMIN 0x0200
2323
#define REQUEST_HTTPGET 0x0100
24-
#define REQUEST_HTTPBULK 0x0080
24+
#define REQUEST_HTTPPURGE 0x0080
2525
#define REQUEST_HTTPPUT 0x0040
2626
#define REQUEST_HTTPDELETE 0x0020
2727
#define REQUEST_HTTPHEAD 0x0010

src/core/http_parse.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,9 @@ static inline state_action http_read_requeststartmethod(int epfd, cache_connecti
202202
RBUF_READMOVE(connection->input, n + 1);
203203
return needs_more;
204204
}
205-
else if (n == 4 && rbuf_cmpn(&connection->input, "BULK", 4) == 0) {
205+
else if (n == 4 && (rbuf_cmpn(&connection->input, "BULK", 4) == 0 || rbuf_cmpn(&connection->input, "PURGE", 5) == 0)) {
206206
//This is a BULK request
207-
connection->type = REQUEST_HTTPBULK;
207+
connection->type = REQUEST_HTTPPURGE;
208208
assert(REQUEST_IS(connection->type, connection->type));
209209
RBUF_READMOVE(connection->input, n + 1);
210210
DEBUG("[#%d] HTTP BULK Request\n", connection->client_sock);
@@ -276,7 +276,7 @@ static inline state_action http_read_requeststarturl1(int epfd, cache_connection
276276
return needs_more;
277277
}
278278
else if (*buffer == ' ') {
279-
if (REQUEST_IS(connection->type, REQUEST_HTTPGET) || REQUEST_IS(connection->type, REQUEST_HTTPDELETE) || REQUEST_IS(connection->type, REQUEST_HTTPBULK)) {
279+
if (REQUEST_IS(connection->type, REQUEST_HTTPGET) || REQUEST_IS(connection->type, REQUEST_HTTPDELETE) || REQUEST_IS(connection->type, REQUEST_HTTPPURGE)) {
280280
//Request for "/"
281281
if (n == 1) {
282282
//Stats Command
@@ -374,7 +374,7 @@ static state_action http_read_headers(int epfd, cache_connection* connection, ch
374374
return needs_more;
375375
}
376376
}
377-
else if (REQUEST_IS(connection->type, REQUEST_HTTPBULK | REQUEST_LEVELTABLE)) {
377+
else if (REQUEST_IS(connection->type, REQUEST_HTTPPURGE | REQUEST_LEVELTABLE)) {
378378
if (bytes == 8 && rbuf_cmpn(&connection->input, "X-Delete", 8) == 0) {
379379
DEBUG("[#%d] Found X-Delete header\n", connection->client_sock);
380380
RBUF_READMOVE(connection->input, bytes + 1);
@@ -441,7 +441,7 @@ static state_action http_read_headers(int epfd, cache_connection* connection, ch
441441
db_table_handle_delete(connection->target.table.table);
442442
return http_write_response(epfd, connection, HTTPTEMPLATE_FULLHTTP200DELETED);
443443
}
444-
if (REQUEST_IS(connection->type, REQUEST_HTTPBULK)) {
444+
if (REQUEST_IS(connection->type, REQUEST_HTTPPURGE)) {
445445
return http_write_response(epfd, connection, HTTPTEMPLATE_BULK_OK);
446446
}
447447
if (REQUEST_IS(connection->type, REQUEST_HTTPADMIN)) {
@@ -573,7 +573,7 @@ static state_action http_read_header_extraction(int epfd, cache_connection* conn
573573
break;
574574

575575
case HEADER_XDELETE:
576-
if (REQUEST_IS(connection->type, REQUEST_HTTPBULK | REQUEST_LEVELTABLE) && connection->target.table.table != NULL) {
576+
if (REQUEST_IS(connection->type, REQUEST_HTTPPURGE | REQUEST_LEVELTABLE) && connection->target.table.table != NULL) {
577577
char* key = (char*)malloc(length);
578578
rbuf_copyn(&connection->input, key, length);
579579
cache_entry* entry = db_entry_get_delete(connection->target.table.table, key, length);

0 commit comments

Comments
 (0)