merged from sandbox

personal/stbuehler/wip
Thomas Porzelt 14 years ago
commit 3d1ce91482
  1. 14
      src/request.c
  2. 2
      src/url_parser.h
  3. 6
      src/url_parser.rl

@ -117,23 +117,23 @@ void request_validate_header(server *srv, connection *con) {
return;
} else if (hh) {
g_string_append_len(req->uri.host, GSTR_LEN((GString*) g_queue_peek_head(&hh->values)));
if (parse_authority(&req->uri)) {
if (parse_hostname(&req->uri)) {
bad_request(srv, con, 400); /* bad request */
return;
}
}
/* may override hostname */
if (!request_parse_url(srv, con)) {
/* Need hostname in HTTP/1.1 */
if (req->uri.host->len == 0 && req->http_version == HTTP_VERSION_1_1) {
bad_request(srv, con, 400); /* bad request */
return;
}
/* Need hostname in HTTP/1.1 */
if (req->uri.host->len == 0 && req->http_version == HTTP_VERSION_1_1) {
/* may override hostname */
if (!request_parse_url(srv, con)) {
bad_request(srv, con, 400); /* bad request */
return;
}
}
/* content-length */
hh = http_header_lookup_fast(req->headers, CONST_STR_LEN("content-length"));
@ -228,8 +228,6 @@ void request_validate_header(server *srv, connection *con) {
/* the may have a content-length */
break;
}
/* TODO: check hostname */
}
void physical_init(physical *phys) {

@ -5,6 +5,6 @@
#include "request.h"
LI_API gboolean parse_raw_url(request_uri *uri);
LI_API gboolean parse_authority(request_uri *uri);
LI_API gboolean parse_hostname(request_uri *uri);
#endif

@ -68,7 +68,7 @@
URI = scheme "://" (authority >mark %save_authority) URI_path;
parse_URI := URI | ("*" >mark %save_path) | URI_path;
parse_Authority := authority;
parse_Hostname := (host >mark_host %save_host) ( ":" port )?;
write data;
}%%
@ -89,7 +89,7 @@ gboolean parse_raw_url(request_uri *uri) {
return (cs >= url_parser_first_final);
}
gboolean parse_authority(request_uri *uri) {
gboolean parse_hostname(request_uri *uri) {
const char *p, *pe, *eof;
const char *mark = NULL, *host_mark = NULL;
int cs;
@ -99,7 +99,7 @@ gboolean parse_authority(request_uri *uri) {
eof = pe = uri->authority->str + uri->authority->len;
%% write init nocs;
cs = url_parser_en_parse_Authority;
cs = url_parser_en_parse_Hostname;
%% write exec;

Loading…
Cancel
Save