chore(lnm): copied over http constants
All checks were successful
ci/woodpecker/push/build Pipeline was successful
All checks were successful
ci/woodpecker/push/build Pipeline was successful
This commit is contained in:
parent
f79ba2818c
commit
c7b3f68c2e
5 changed files with 211 additions and 3 deletions
|
|
@ -1,3 +1,6 @@
|
|||
#ifndef LNM_LOOP_INTERNAL
|
||||
#define LNM_LOOP_INTERNAL
|
||||
|
||||
#include "lnm/loop.h"
|
||||
|
||||
lnm_err lnm_loop_conn_init(lnm_loop_conn **out, lnm_loop *l);
|
||||
|
|
@ -7,3 +10,5 @@ void lnm_loop_conn_free(lnm_loop *l, lnm_loop_conn *conn);
|
|||
lnm_err lnm_loop_accept(lnm_loop *l);
|
||||
|
||||
void lnm_loop_conn_io(lnm_loop *l, lnm_loop_conn *conn);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
100
lnm/src/http/lnm_http_consts.c
Normal file
100
lnm/src/http/lnm_http_consts.c
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
#include "lnm/http/consts.h"
|
||||
|
||||
const char *lnm_http_method_names[] = {"GET", "POST", "PUT", "PATCH", "DELETE"};
|
||||
const size_t lnm_http_method_names_len =
|
||||
sizeof(lnm_http_method_names) / sizeof(lnm_http_method_names[0]);
|
||||
|
||||
// clang-format off
|
||||
|
||||
const char *lnm_http_status_names[][32] = {
|
||||
// 1xx
|
||||
{
|
||||
"Continue", // 100
|
||||
"Switching Protocols", // 101,
|
||||
"Processing", // 102
|
||||
"Early Hints", // 103
|
||||
},
|
||||
// 2xx
|
||||
{
|
||||
"OK", // 200
|
||||
"Created", // 201
|
||||
"Accepted", // 202
|
||||
"Non-Authoritative Information", // 203
|
||||
"No Content", // 204
|
||||
"Reset Content", // 205
|
||||
"Partial Content", // 206
|
||||
"Multi-Status", // 207
|
||||
"Already Reported", // 208
|
||||
},
|
||||
// 3xx
|
||||
{
|
||||
"Multiple Choices", // 300
|
||||
"Moved Permanently", // 301
|
||||
"Found", // 302
|
||||
"See Other", // 303
|
||||
"Not Modified", // 304
|
||||
NULL, // 305
|
||||
NULL, // 306
|
||||
"Temporary Redirect", // 307
|
||||
"Permanent Redirect", // 308
|
||||
},
|
||||
// 4xx
|
||||
{
|
||||
"Bad Request", // 400
|
||||
"Unauthorized", // 401
|
||||
"Payment Required", // 402
|
||||
"Forbidden", // 403
|
||||
"Not Found", // 404
|
||||
"Method Not Allowed", // 405
|
||||
"Not Acceptable", // 406
|
||||
"Proxy Authentication Required", // 407
|
||||
"Request Timeout", // 408
|
||||
"Conflict", // 409
|
||||
"Gone", // 410
|
||||
"Length Required", // 411
|
||||
"Precondition Failed", // 412
|
||||
"Content Too Large", // 413
|
||||
"URI Too Long", // 414
|
||||
"Unsupported Media Type", // 415
|
||||
"Range Not Satisfiable", // 416
|
||||
"Expectation Failed", // 417
|
||||
"I'm a teapot", // 418
|
||||
NULL, // 419
|
||||
NULL, // 420
|
||||
"Misdirected Request", // 421
|
||||
"Unprocessable Content", // 422
|
||||
"Locked", // 423
|
||||
"Failed Dependency", // 424
|
||||
"Too Early", // 425
|
||||
"Upgrade Required", // 426
|
||||
NULL, // 427
|
||||
"Precondition Required", // 428
|
||||
"Too Many Requests", // 429
|
||||
NULL, // 430
|
||||
"Request Header Fields Too Large", // 431
|
||||
},
|
||||
// 5xx
|
||||
{
|
||||
"Internal Server Error", // 500
|
||||
"Not Implemented", // 501
|
||||
"Bad Gateway", // 502
|
||||
"Service Unavailable", // 503
|
||||
"Gateway Timeout", // 504
|
||||
"HTTP Version Not Supported", // 505
|
||||
"Variant Also Negotiates", // 506
|
||||
"Insufficient Storage", // 507
|
||||
"Loop Detected", // 508
|
||||
NULL, // 509
|
||||
"Not Extended", // 510
|
||||
"Network Authentication Required" // 511
|
||||
},
|
||||
};
|
||||
|
||||
const char *lnm_http_header_names[] = {
|
||||
"Connection",
|
||||
"Location",
|
||||
"Content-Type",
|
||||
"Content-Disposition",
|
||||
"Server",
|
||||
"Content-Length"
|
||||
};
|
||||
|
|
@ -8,7 +8,9 @@
|
|||
|
||||
lnm_err lnm_loop_init(lnm_loop **out, void *gctx,
|
||||
lnm_err (*ctx_init)(void **out, void *gctx),
|
||||
void (*ctx_free)(void *ctx)) {
|
||||
void (*ctx_free)(void *ctx),
|
||||
void (*data_read)(lnm_loop_conn *conn),
|
||||
void (*data_write)(lnm_loop_conn *conn)) {
|
||||
lnm_loop *l = calloc(1, sizeof(lnm_loop));
|
||||
|
||||
if (l == NULL) {
|
||||
|
|
@ -18,6 +20,8 @@ lnm_err lnm_loop_init(lnm_loop **out, void *gctx,
|
|||
l->gctx = gctx;
|
||||
l->ctx_init = ctx_init;
|
||||
l->ctx_free = ctx_free;
|
||||
l->data_read = data_read;
|
||||
l->data_write = data_write;
|
||||
|
||||
*out = l;
|
||||
|
||||
|
|
@ -121,7 +125,7 @@ lnm_err lnm_loop_run(lnm_loop *l) {
|
|||
// Add all open connections to the poll command
|
||||
for (size_t i = 0; i < l->conns.len && poll_args_len < l->conns.open + 1;
|
||||
i++) {
|
||||
lnm_loop_conn *conn = l->conns.arr[i];
|
||||
const lnm_loop_conn *conn = l->conns.arr[i];
|
||||
|
||||
if (conn == NULL) {
|
||||
continue;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue