4 Commits

7 changed files with 18 additions and 14 deletions

View File

@@ -10,8 +10,8 @@
#define SESIMOS_DEF_H
#define SERVER_VERSION "4.6"
#define SERVER_STR "Sesimos/" SERVER_VERSION
#define SERVER_STR_HTML "Sesimos web server " SERVER_VERSION
#define SERVER_STR "sesimos/" SERVER_VERSION
#define SERVER_STR_HTML "sesimos web server " SERVER_VERSION
#define CHUNK_SIZE 8192
#define MAX_PROXY_CNX_PER_HOST 16

View File

@@ -40,11 +40,11 @@
#define HTTP_MAX_HEADER_FIELD_NUM 64
#ifndef SERVER_STR
# define SERVER_STR "Sesimos"
# define SERVER_STR "sesimos"
#endif
#ifndef SERVER_STR_HTML
# define SERVER_STR_HTML "Sesimos web server"
# define SERVER_STR_HTML "sesimos web server"
#endif
typedef struct {

View File

@@ -142,7 +142,7 @@ int main(int argc, char *const argv[]) {
critical("Unable to set stdout/stderr to line-buffered mode");
return 1;
}
printf("Sesimos web server " SERVER_VERSION "\n");
printf("sesimos web server " SERVER_VERSION "\n");
static const struct option long_opts[] = {
{"help", no_argument, 0, 'h'},

View File

@@ -19,10 +19,9 @@ static int fastcgi_handler_1(client_ctx_t *ctx, fastcgi_cnx_t *fcgi_cnx);
static int fastcgi_handler_2(client_ctx_t *ctx, fastcgi_cnx_t *fcgi_cnx);
void fastcgi_handler_func(client_ctx_t *ctx) {
fastcgi_cnx_t fcgi_cnx;
logger_set_prefix("[%s%*s%s]%s", BLD_STR, INET6_ADDRSTRLEN, ctx->req_host, CLR_STR, ctx->log_prefix);
// TODO
fastcgi_cnx_t fcgi_cnx;
fastcgi_handler_1(ctx, &fcgi_cnx);
respond(ctx);
fastcgi_handler_2(ctx, &fcgi_cnx);

View File

@@ -44,7 +44,6 @@ static int local_handler(client_ctx_t *ctx) {
int accept_if_modified_since = 0;
if (strcmp(req->method, "TRACE") == 0) {
// FIXME not working?
res->status = http_get_status(200);
http_add_header_field(&res->hdr, "Content-Type", "message/http");

View File

@@ -16,7 +16,6 @@
#include "../server.h"
#include <string.h>
#include <openssl/err.h>
#include <arpa/inet.h>
static int request_handler(client_ctx_t *ctx);
@@ -27,6 +26,7 @@ void request_handler_func(client_ctx_t *ctx) {
switch (request_handler(ctx)) {
case 0:
respond(ctx);
request_complete(ctx);
handle_request(ctx);
break;
case 1:
@@ -156,10 +156,12 @@ static int request_handler(client_ctx_t *ctx) {
return 0;
}
if (dir_mode != URI_DIR_MODE_NO_VALIDATION) {
if (ctx->conf->type == CONFIG_TYPE_LOCAL && strcmp(req->method, "TRACE") == 0) {
return 1;
} else if (dir_mode != URI_DIR_MODE_NO_VALIDATION) {
ssize_t size = sizeof(buf0);
url_decode(req->uri, buf0, &size);
int change_proto = strncmp(uri->uri, "/.well-known/", 13) != 0 && !client->enc;
int change_proto = (!client->enc && strncmp(uri->uri, "/.well-known/", 13) != 0);
if (strcmp(uri->uri, buf0) != 0 || change_proto) {
res->status = http_get_status(308);
size = url_encode(uri->uri, strlen(uri->uri), buf0, sizeof(buf0));
@@ -214,7 +216,7 @@ int respond(client_ctx_t *ctx) {
if (http_get_header_field(&res->hdr, "Accept-Ranges") == NULL) {
http_add_header_field(&res->hdr, "Accept-Ranges", "none");
}
if (!ctx->use_fastcgi && ctx->file == NULL) {
if (!ctx->use_fastcgi && ctx->file == NULL && ctx->msg_buf[0] == 0) {
http_remove_header_field(&res->hdr, "Date", HTTP_REMOVE_ALL);
http_remove_header_field(&res->hdr, "Server", HTTP_REMOVE_ALL);
http_remove_header_field(&res->hdr, "Cache-Control", HTTP_REMOVE_ALL);

View File

@@ -56,7 +56,11 @@ static int handle_request_cb(client_ctx_t *ctx) {
}
int handle_request(client_ctx_t *ctx) {
return async(ctx->socket.socket, POLLIN, 0, (void (*)(void *)) handle_request_cb, ctx, (void (*)(void *)) tcp_close, ctx);
if (ctx->c_keep_alive && ctx->s_keep_alive) {
return async(ctx->socket.socket, POLLIN, 0, (void (*)(void *)) handle_request_cb, ctx, (void (*)(void *)) tcp_close, ctx);
} else {
return tcp_close(ctx);
}
}
int local_handle(client_ctx_t *ctx) {