[core] move http_request_headers_process()

move http_request_headers_process() to request.[ch]
master
Glenn Strauss 2 years ago
parent db7b51a4f6
commit 6971c6c811
  1. 1
      src/CMakeLists.txt
  2. 2
      src/Makefile.am
  3. 34
      src/connections.c
  4. 1
      src/meson.build
  5. 40
      src/request.c
  6. 2
      src/request.h
  7. 2
      src/t/test_request.c

@ -909,7 +909,6 @@ add_test(NAME test_mod_userdir COMMAND test_mod_userdir)
add_executable(test_request
t/test_request.c
request.c
base64.c
buffer.c
burl.c

@ -615,7 +615,7 @@ t_test_mod_simple_vhost_LDADD = $(LIBUNWIND_LIBS)
t_test_mod_userdir_SOURCES = t/test_mod_userdir.c buffer.c array.c data_integer.c data_string.c log.c
t_test_mod_userdir_LDADD = $(LIBUNWIND_LIBS)
t_test_request_SOURCES = t/test_request.c request.c base64.c buffer.c burl.c array.c data_integer.c data_string.c http_header.c http_kv.c log.c sock_addr.c
t_test_request_SOURCES = t/test_request.c base64.c buffer.c burl.c array.c data_integer.c data_string.c http_header.c http_kv.c log.c sock_addr.c
t_test_request_LDADD = $(LIBUNWIND_LIBS)
noinst_HEADERS = $(hdr)

@ -813,40 +813,6 @@ static chunk * connection_read_header_more(connection *con, chunkqueue *cq, chun
: NULL;
}
static void
http_request_headers_process (request_st * const r, char * const hdrs, unsigned short * const hoff, const int scheme_port)
{
r->http_status = http_request_parse(r, hdrs, hoff, scheme_port);
if (0 == r->http_status) {
#if 0
r->conditional_is_valid = (1 << COMP_SERVER_SOCKET)
| (1 << COMP_HTTP_SCHEME)
| (1 << COMP_HTTP_HOST)
| (1 << COMP_HTTP_REMOTE_IP)
| (1 << COMP_HTTP_REQUEST_METHOD)
| (1 << COMP_HTTP_URL)
| (1 << COMP_HTTP_QUERY_STRING)
| (1 << COMP_HTTP_REQUEST_HEADER);
#else
/* all config conditions are valid after parsing header
* (set all bits; remove dependency on plugin_config.h) */
r->conditional_is_valid = ~0u;
#endif
}
else {
r->keep_alive = 0;
r->reqbody_length = 0;
if (r->conf.log_request_header_on_error) {
/*(http_request_parse() modifies hdrs only to
* undo line-wrapping in-place using spaces)*/
log_error(r->conf.errh, __FILE__, __LINE__,
"request-header:\n%.*s", (int)r->rqst_header_len, hdrs);
}
}
}
/**
* handle request header read

@ -900,7 +900,6 @@ test('test_mod_userdir', executable('test_mod_userdir',
test('test_request', executable('test_request',
sources: [
't/test_request.c',
'request.c',
'base64.c',
'buffer.c',
'burl.c',

@ -1085,7 +1085,10 @@ static int http_request_parse_headers(request_st * const restrict r, char * cons
return 0;
}
int http_request_parse(request_st * const restrict r, char * const restrict hdrs, const unsigned short * const restrict hoff, const int scheme_port) {
static int
http_request_parse (request_st * const restrict r, char * const restrict hdrs, const unsigned short * const restrict hoff, const int scheme_port)
{
/*
* Request: "^(GET|POST|HEAD|...) ([^ ]+(\\?[^ ]+|)) (HTTP/1\\.[01])$"
* Header : "^([-a-zA-Z]+): (.+)$"
@ -1164,3 +1167,38 @@ int http_request_parse(request_st * const restrict r, char * const restrict hdrs
return 0;
}
void
http_request_headers_process (request_st * const restrict r, char * const restrict hdrs, const unsigned short * const restrict hoff, const int scheme_port)
{
r->http_status = http_request_parse(r, hdrs, hoff, scheme_port);
if (0 == r->http_status) {
#if 0
r->conditional_is_valid = (1 << COMP_SERVER_SOCKET)
| (1 << COMP_HTTP_SCHEME)
| (1 << COMP_HTTP_HOST)
| (1 << COMP_HTTP_REMOTE_IP)
| (1 << COMP_HTTP_REQUEST_METHOD)
| (1 << COMP_HTTP_URL)
| (1 << COMP_HTTP_QUERY_STRING)
| (1 << COMP_HTTP_REQUEST_HEADER);
#else
/* all config conditions are valid after parsing header
* (set all bits; remove dependency on plugin_config.h) */
r->conditional_is_valid = ~0u;
#endif
}
else {
r->keep_alive = 0;
r->reqbody_length = 0;
if (r->conf.log_request_header_on_error) {
/*(http_request_parse() modifies hdrs only to
* undo line-wrapping in-place using spaces)*/
log_error(r->conf.errh, __FILE__, __LINE__,
"request-header:\n%.*s", (int)r->rqst_header_len, hdrs);
}
}
}

@ -188,7 +188,7 @@ struct request_st {
};
int http_request_parse(request_st * restrict r, char * restrict hdrs, const unsigned short * restrict hloffsets, int scheme_port);
void http_request_headers_process (request_st * restrict r, char * restrict hdrs, const unsigned short * restrict hoff, int scheme_port);
int http_request_parse_target(request_st *r, int scheme_port);
int http_request_host_normalize(buffer *b, int scheme_port);
int http_request_host_policy(buffer *b, unsigned int http_parseopts, int scheme_port);

@ -6,7 +6,7 @@
#include <stdio.h>
#include <string.h>
#include "request.h"
#include "request.c"
static void test_request_reset(request_st * const r)
{

Loading…
Cancel
Save