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> #include <stddef.h>
enum http_method {
HTTP_GET = 1,
HTTP_PUT = 2,
HTTP_OPTIONS = 4,
};
struct http_kv { struct http_kv {
char* key; char* key;
char* value; char* value;
}; };
struct http_req { struct http_req {
enum http_method method;
size_t header_length; size_t header_length;
size_t content_length; size_t content_length;
char* content_type; 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) static int http__get(struct http_req* req, struct httplex* lex)
{ {
if (!http__literal(lex, "GET")) return 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;
} }
static int http__method(struct http_req* req, struct httplex* lex) static int http__method(struct http_req* req, struct httplex* lex)
{ {
return http__get(req, lex) return http__get(req, lex);
|| http__put(req, lex)
|| http__options(req, lex);
} }
static int http__peek(struct httplex* lex, enum httplex_token_type type) static int http__peek(struct httplex* lex, enum httplex_token_type type)