enum http_request_parse_error *error_code_r, const char **error_r)
{
const struct http_header_field *hdr;
- const char *error;
+ const char *host_hdr, *error;
int ret;
/* initialize and get rid of any payload of previous request */
request message that contains more than one Host header field or a
Host header field with an invalid field-value.
*/
- if ((ret=http_header_field_find_unique
- (parser->parser.msg.header, "Host", &hdr)) <= 0) {
- *error_code_r = HTTP_REQUEST_PARSE_ERROR_BAD_REQUEST;
- if (ret == 0)
- *error_r = "Missing Host header";
- else
- *error_r = "Duplicate Host header";
- return -1;
+ host_hdr = NULL;
+ if (parser->parser.msg.version_major == 1 &&
+ parser->parser.msg.version_minor > 0) {
+ if ((ret=http_header_field_find_unique(
+ parser->parser.msg.header, "Host", &hdr)) <= 0) {
+ *error_code_r = HTTP_REQUEST_PARSE_ERROR_BAD_REQUEST;
+ if (ret == 0)
+ *error_r = "Missing Host header";
+ else
+ *error_r = "Duplicate Host header";
+ return -1;
+ }
+
+ host_hdr = hdr->value;
}
i_zero(request);
pool = http_message_parser_get_pool(&parser->parser);
- if (http_url_request_target_parse(parser->request_target, hdr->value,
+ if (http_url_request_target_parse(parser->request_target, host_hdr,
parser->default_base_url, pool, &request->target, &error) < 0) {
*error_code_r = HTTP_REQUEST_PARSE_ERROR_BAD_REQUEST;
*error_r = t_strdup_printf("Bad request target `%s': %s",
},
.version_major = 1, .version_minor = 1,
},{ .request =
- "OPTIONS * HTTP/1.0\r\n"
+ "GET / HTTP/1.0\r\n"
+ "\r\n",
+ .method = "GET",
+ .target_raw = "/",
+ .target = {
+ .format = HTTP_REQUEST_TARGET_FORMAT_ORIGIN,
+ .url = { .host = { .name = "example.org" } }
+ },
+ .version_major = 1, .version_minor = 0,
+ .connection_close = TRUE,
+ },{ .request =
+ "OPTIONS * HTTP/1.1\r\n"
"Host: example.com\r\n"
"Connection: Keep-Alive\r\n"
"\r\n",
.format = HTTP_REQUEST_TARGET_FORMAT_ASTERISK,
.url = { .host = { .name = "example.com" } }
},
+ .version_major = 1, .version_minor = 1,
+ },{ .request =
+ "OPTIONS * HTTP/1.0\r\n"
+ "Connection: Keep-Alive\r\n"
+ "\r\n",
+ .method = "OPTIONS",
+ .target_raw = "*",
+ .target = {
+ .format = HTTP_REQUEST_TARGET_FORMAT_ASTERISK,
+ .url = { .host = { .name = "example.org" } }
+ },
.version_major = 1, .version_minor = 0,
},{ .request =
"CONNECT example.com:443 HTTP/1.2\r\n"