http: Only support GET method

pull/68/head
Andri Yngvason 2023-04-30 14:31:34 +00:00
parent 2f439b9fa2
commit c006936fd0
2 changed files with 2 additions and 33 deletions

View File

@ -20,19 +20,12 @@
#include <stddef.h>
enum http_method {
HTTP_GET = 1,
HTTP_PUT = 2,
HTTP_OPTIONS = 4,
};
struct http_kv {
char* key;
char* value;
};
struct http_req {
enum http_method method;
size_t header_length;
size_t content_length;
char* content_type;

View File

@ -262,36 +262,12 @@ static int http__literal(struct httplex* lex, const char* str)
static int http__get(struct http_req* req, struct httplex* lex)
{
if (!http__literal(lex, "GET"))
return 0;
req->method = HTTP_GET;
return 1;
}
static int http__put(struct http_req* req, struct httplex* lex)
{
if (!http__literal(lex, "PUT"))
return 0;
req->method = HTTP_PUT;
return 1;
}
static int http__options(struct http_req* req, struct httplex* lex)
{
if (!http__literal(lex, "OPTIONS"))
return 0;
req->method = HTTP_OPTIONS;
return 1;
return http__literal(lex, "GET");
}
static int http__method(struct http_req* req, struct httplex* lex)
{
return http__get(req, lex)
|| http__put(req, lex)
|| http__options(req, lex);
return http__get(req, lex);
}
static int http__peek(struct httplex* lex, enum httplex_token_type type)