From 03103b5a44e48735a1fe24156c7859c530298fad Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Mon, 13 Apr 2009 18:40:50 +0000 Subject: Move S3Simulator into its own class, like S3Client, for reuse elsewhere. --- lib/httpserver/HTTPRequest.cpp | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'lib/httpserver/HTTPRequest.cpp') diff --git a/lib/httpserver/HTTPRequest.cpp b/lib/httpserver/HTTPRequest.cpp index e146a0a3..4c5dc149 100644 --- a/lib/httpserver/HTTPRequest.cpp +++ b/lib/httpserver/HTTPRequest.cpp @@ -535,9 +535,11 @@ void HTTPRequest::ParseHeaders(IOStreamGetLine &rGetLine, int Timeout) { ++dataStart; } - - if(p == sizeof("Content-Length")-1 - && ::strncasecmp(h, "Content-Length", sizeof("Content-Length")-1) == 0) + + std::string header_name(ToLowerCase(std::string(h, + p))); + + if (header_name == "content-length") { // Decode number long len = ::strtol(h + dataStart, NULL, 10); // returns zero in error case, this is OK @@ -545,14 +547,12 @@ void HTTPRequest::ParseHeaders(IOStreamGetLine &rGetLine, int Timeout) // Store mContentLength = len; } - else if(p == sizeof("Content-Type")-1 - && ::strncasecmp(h, "Content-Type", sizeof("Content-Type")-1) == 0) + else if (header_name == "content-type") { // Store rest of string as content type mContentType = h + dataStart; } - else if(p == sizeof("Host")-1 - && ::strncasecmp(h, "Host", sizeof("Host")-1) == 0) + else if (header_name == "host") { // Store host header mHostName = h + dataStart; @@ -572,14 +572,12 @@ void HTTPRequest::ParseHeaders(IOStreamGetLine &rGetLine, int Timeout) "port = " << mHostPort); } } - else if(p == sizeof("Cookie")-1 - && ::strncasecmp(h, "Cookie", sizeof("Cookie")-1) == 0) + else if (header_name == "cookie") { // Parse cookies ParseCookies(header, dataStart); } - else if(p == sizeof("Connection")-1 - && ::strncasecmp(h, "Connection", sizeof("Connection")-1) == 0) + else if (header_name == "connection") { // Connection header, what is required? const char *v = h + dataStart; @@ -595,8 +593,7 @@ void HTTPRequest::ParseHeaders(IOStreamGetLine &rGetLine, int Timeout) } else { - std::string name = header.substr(0, p); - mExtraHeaders.push_back(Header(name, + mExtraHeaders.push_back(Header(header_name, h + dataStart)); } -- cgit v1.2.3