Update http_static
This commit is contained in:
@ -39,6 +39,12 @@
|
|||||||
#define CLIENT_MAX_HEADER_SIZE 8192
|
#define CLIENT_MAX_HEADER_SIZE 8192
|
||||||
#define HTTP_INIT_HEADER_FIELD_NUM 16
|
#define HTTP_INIT_HEADER_FIELD_NUM 16
|
||||||
|
|
||||||
|
#define HTTP_TYPE_INFORMATIONAL 1
|
||||||
|
#define HTTP_TYPE_SUCCESS 2
|
||||||
|
#define HTTP_TYPE_REDIRECTION 3
|
||||||
|
#define HTTP_TYPE_CLIENT_ERROR 4
|
||||||
|
#define HTTP_TYPE_SERVER_ERROR 5
|
||||||
|
|
||||||
#ifndef SERVER_STR
|
#ifndef SERVER_STR
|
||||||
# define SERVER_STR "sesimos"
|
# define SERVER_STR "sesimos"
|
||||||
#endif
|
#endif
|
||||||
@ -48,13 +54,13 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
unsigned short code;
|
unsigned short code:10;
|
||||||
char type[16];
|
unsigned char type:3;
|
||||||
char msg[64];
|
char msg[64];
|
||||||
} http_status;
|
} http_status;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
unsigned short code;
|
unsigned short code:10;
|
||||||
const char *msg;
|
const char *msg;
|
||||||
} http_status_msg;
|
} http_status_msg;
|
||||||
|
|
||||||
|
@ -9,51 +9,51 @@
|
|||||||
#include "http.h"
|
#include "http.h"
|
||||||
|
|
||||||
const http_status http_statuses[] = {
|
const http_status http_statuses[] = {
|
||||||
{100, "Informational", "Continue"},
|
{100, HTTP_TYPE_INFORMATIONAL, "Continue"},
|
||||||
{101, "Informational", "Switching Protocols"},
|
{101, HTTP_TYPE_INFORMATIONAL, "Switching Protocols"},
|
||||||
|
|
||||||
{200, "Success", "OK"},
|
{200, HTTP_TYPE_SUCCESS, "OK"},
|
||||||
{201, "Success", "Created"},
|
{201, HTTP_TYPE_SUCCESS, "Created"},
|
||||||
{202, "Success", "Accepted"},
|
{202, HTTP_TYPE_SUCCESS, "Accepted"},
|
||||||
{203, "Success", "Non-Authoritative Information"},
|
{203, HTTP_TYPE_SUCCESS, "Non-Authoritative Information"},
|
||||||
{204, "Success", "No Content"},
|
{204, HTTP_TYPE_SUCCESS, "No Content"},
|
||||||
{205, "Success", "Reset Content"},
|
{205, HTTP_TYPE_SUCCESS, "Reset Content"},
|
||||||
{206, "Success", "Partial Content"},
|
{206, HTTP_TYPE_SUCCESS, "Partial Content"},
|
||||||
|
|
||||||
{300, "Redirection", "Multiple Choices"},
|
{300, HTTP_TYPE_REDIRECTION, "Multiple Choices"},
|
||||||
{301, "Redirection", "Moved Permanently"},
|
{301, HTTP_TYPE_REDIRECTION, "Moved Permanently"},
|
||||||
{302, "Redirection", "Found"},
|
{302, HTTP_TYPE_REDIRECTION, "Found"},
|
||||||
{303, "Redirection", "See Other"},
|
{303, HTTP_TYPE_REDIRECTION, "See Other"},
|
||||||
{304, "Success", "Not Modified"},
|
{304, HTTP_TYPE_SUCCESS, "Not Modified"},
|
||||||
{305, "Redirection", "Use Proxy"},
|
{305, HTTP_TYPE_REDIRECTION, "Use Proxy"},
|
||||||
{307, "Redirection", "Temporary Redirect"},
|
{307, HTTP_TYPE_REDIRECTION, "Temporary Redirect"},
|
||||||
{308, "Redirection", "Permanent Redirect"},
|
{308, HTTP_TYPE_REDIRECTION, "Permanent Redirect"},
|
||||||
|
|
||||||
{400, "Client Error", "Bad Request"},
|
{400, HTTP_TYPE_CLIENT_ERROR, "Bad Request"},
|
||||||
{401, "Client Error", "Unauthorized"},
|
{401, HTTP_TYPE_CLIENT_ERROR, "Unauthorized"},
|
||||||
{402, "Client Error", "Payment Required"},
|
{402, HTTP_TYPE_CLIENT_ERROR, "Payment Required"},
|
||||||
{403, "Client Error", "Forbidden"},
|
{403, HTTP_TYPE_CLIENT_ERROR, "Forbidden"},
|
||||||
{404, "Client Error", "Not Found"},
|
{404, HTTP_TYPE_CLIENT_ERROR, "Not Found"},
|
||||||
{405, "Client Error", "Method Not Allowed"},
|
{405, HTTP_TYPE_CLIENT_ERROR, "Method Not Allowed"},
|
||||||
{406, "Client Error", "Not Acceptable"},
|
{406, HTTP_TYPE_CLIENT_ERROR, "Not Acceptable"},
|
||||||
{407, "Client Error", "Proxy Authentication Required"},
|
{407, HTTP_TYPE_CLIENT_ERROR, "Proxy Authentication Required"},
|
||||||
{408, "Client Error", "Request Timeout"},
|
{408, HTTP_TYPE_CLIENT_ERROR, "Request Timeout"},
|
||||||
{409, "Client Error", "Conflict"},
|
{409, HTTP_TYPE_CLIENT_ERROR, "Conflict"},
|
||||||
{410, "Client Error", "Gone"},
|
{410, HTTP_TYPE_CLIENT_ERROR, "Gone"},
|
||||||
{411, "Client Error", "Length Required"},
|
{411, HTTP_TYPE_CLIENT_ERROR, "Length Required"},
|
||||||
{412, "Client Error", "Precondition Failed"},
|
{412, HTTP_TYPE_CLIENT_ERROR, "Precondition Failed"},
|
||||||
{413, "Client Error", "Request Entity Too Large"},
|
{413, HTTP_TYPE_CLIENT_ERROR, "Request Entity Too Large"},
|
||||||
{414, "Client Error", "Request-URI Too Long"},
|
{414, HTTP_TYPE_CLIENT_ERROR, "Request-URI Too Long"},
|
||||||
{415, "Client Error", "Unsupported Media Type"},
|
{415, HTTP_TYPE_CLIENT_ERROR, "Unsupported Media Type"},
|
||||||
{416, "Client Error", "Range Not Satisfiable"},
|
{416, HTTP_TYPE_CLIENT_ERROR, "Range Not Satisfiable"},
|
||||||
{417, "Client Error", "Expectation Failed"},
|
{417, HTTP_TYPE_CLIENT_ERROR, "Expectation Failed"},
|
||||||
|
|
||||||
{500, "Server Error", "Internal Server Error"},
|
{500, HTTP_TYPE_SERVER_ERROR, "Internal Server Error"},
|
||||||
{501, "Server Error", "Not Implemented"},
|
{501, HTTP_TYPE_SERVER_ERROR, "Not Implemented"},
|
||||||
{502, "Server Error", "Bad Gateway"},
|
{502, HTTP_TYPE_SERVER_ERROR, "Bad Gateway"},
|
||||||
{503, "Server Error", "Service Unavailable"},
|
{503, HTTP_TYPE_SERVER_ERROR, "Service Unavailable"},
|
||||||
{504, "Server Error", "Gateway Timeout"},
|
{504, HTTP_TYPE_SERVER_ERROR, "Gateway Timeout"},
|
||||||
{505, "Server Error", "HTTP Version Not Supported"},
|
{505, HTTP_TYPE_SERVER_ERROR, "HTTP Version Not Supported"},
|
||||||
};
|
};
|
||||||
|
|
||||||
const http_status_msg http_status_messages[] = {
|
const http_status_msg http_status_messages[] = {
|
||||||
|
@ -524,7 +524,7 @@ int proxy_init(proxy_ctx_t **proxy_ptr, http_req *req, http_res *res, http_statu
|
|||||||
res->status = http_get_status(status_code);
|
res->status = http_get_status(status_code);
|
||||||
if (res->status == NULL && status_code >= 100 && status_code <= 999) {
|
if (res->status == NULL && status_code >= 100 && status_code <= 999) {
|
||||||
custom_status->code = status_code;
|
custom_status->code = status_code;
|
||||||
strcpy(custom_status->type, "");
|
custom_status->type = 0;
|
||||||
snprintf(custom_status->msg, sizeof(custom_status->msg), "%.*s",
|
snprintf(custom_status->msg, sizeof(custom_status->msg), "%.*s",
|
||||||
(int) (strchr(ptr, '\r') - ptr - 13), ptr + 13);
|
(int) (strchr(ptr, '\r') - ptr - 13), ptr + 13);
|
||||||
res->status = custom_status;
|
res->status = custom_status;
|
||||||
|
@ -101,7 +101,7 @@ static int fastcgi_handler_1(client_ctx_t *ctx, fastcgi_cnx_t *fcgi_cnx) {
|
|||||||
http_remove_header_field(&res->hdr, "Status", HTTP_REMOVE_ALL);
|
http_remove_header_field(&res->hdr, "Status", HTTP_REMOVE_ALL);
|
||||||
if (res->status == NULL && status_code >= 100 && status_code <= 999) {
|
if (res->status == NULL && status_code >= 100 && status_code <= 999) {
|
||||||
ctx->custom_status.code = status_code;
|
ctx->custom_status.code = status_code;
|
||||||
strcpy(ctx->custom_status.type, "");
|
ctx->custom_status.type = 0;
|
||||||
strcpy(ctx->custom_status.msg, status_hdr + 4);
|
strcpy(ctx->custom_status.msg, status_hdr + 4);
|
||||||
res->status = &ctx->custom_status;
|
res->status = &ctx->custom_status;
|
||||||
} else if (res->status == NULL) {
|
} else if (res->status == NULL) {
|
||||||
|
Reference in New Issue
Block a user