Browse Source

[core] pass scheme port to http_request_parse()

con->proto_default_port is a property of the connection,
which influences the default port used in host normalization
personal/stbuehler/ci-build
Glenn Strauss 2 years ago
parent
commit
6748a58cca
  1. 3
      src/connections.c
  2. 4
      src/request.c
  3. 2
      src/request.h
  4. 3
      src/t/test_request.c

3
src/connections.c

@ -845,7 +845,8 @@ static int connection_handle_read_state(connection * const con) {
(int)con->header_len, hdrs);
}
con->http_status = http_request_parse(con, hdrs, hoff);
con->http_status =
http_request_parse(con, hdrs, hoff, con->proto_default_port);
if (0 != con->http_status) {
con->request.keep_alive = 0;
con->request.content_length = 0;

4
src/request.c

@ -793,7 +793,7 @@ static int http_request_parse_headers(connection * const con, char * const ptr,
return 0;
}
int http_request_parse(connection * const con, char * const hdrs, const unsigned short * const hoff) {
int http_request_parse(connection * const con, char * const hdrs, const unsigned short * const hoff, const int scheme_port) {
/*
* Request: "^(GET|POST|HEAD|...) ([^ ]+(\\?[^ ]+|)) (HTTP/1\\.[01])$"
* Header : "^([-a-zA-Z]+): (.+)$"
@ -814,7 +814,7 @@ int http_request_parse(connection * const con, char * const hdrs, const unsigned
if (con->request.http_host) {
if (0 != http_request_host_policy(con->request.http_host,
con->conf.http_parseopts,
con->proto_default_port))
scheme_port))
return http_request_header_line_invalid(con, 400, "Invalid Hostname -> 400");
}
else {

2
src/request.h

@ -5,7 +5,7 @@
#include "base_decls.h"
#include "buffer.h"
int http_request_parse(connection *con, char *hdrs, const unsigned short *hloffsets);
int http_request_parse(connection *con, char *hdrs, const unsigned short *hloffsets, 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);

3
src/t/test_request.c

@ -40,7 +40,8 @@ static void run_http_request_parse(connection *con, int line, int status, const
hloffsets[hloffsets[0]] = n - req + 1;
}
--hloffsets[0]; /*(ignore final blank line "\r\n" ending headers)*/
int http_status = http_request_parse(con, hdrs->ptr, hloffsets);
int http_status =
http_request_parse(con, hdrs->ptr, hloffsets, con->proto_default_port);
if (http_status != status) {
fprintf(stderr,
"%s.%d: %s() failed: expected '%d', got '%d' for test %s\n",

Loading…
Cancel
Save