From 513887fa529c681958c57a946dade81f3c11d616 Mon Sep 17 00:00:00 2001 From: Glenn Strauss Date: Tue, 3 Oct 2017 01:56:43 -0400 Subject: [PATCH] [core] URI scheme is case-insensitive check case-insensitive scheme if full URI provided in request-line RFC7230: The scheme and host are case-insensitive and normally provided in lowercase; all other components are compared in a case-sensitive manner. x-ref: "https://redmine.lighttpd.net/boards/3/topics/7637" --- src/request.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/request.c b/src/request.c index d042d0b8..65fcddf6 100644 --- a/src/request.c +++ b/src/request.c @@ -587,13 +587,16 @@ int http_request_parse(server *srv, connection *con) { return 0; } - if (0 == strncmp(uri, "http://", 7) && + if (*uri == '/') { + /* (common case) */ + buffer_copy_string_len(con->request.uri, uri, proto - uri - 1); + } else if (0 == strncasecmp(uri, "http://", 7) && NULL != (nuri = strchr(uri + 7, '/'))) { reqline_host = uri + 7; reqline_hostlen = nuri - reqline_host; buffer_copy_string_len(con->request.uri, nuri, proto - nuri - 1); - } else if (0 == strncmp(uri, "https://", 8) && + } else if (0 == strncasecmp(uri, "https://", 8) && NULL != (nuri = strchr(uri + 8, '/'))) { reqline_host = uri + 8; reqline_hostlen = nuri - reqline_host;