diff options
author | Chris Wilson <chris+github@qwirx.com> | 2009-04-13 18:40:50 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2009-04-13 18:40:50 +0000 |
commit | 03103b5a44e48735a1fe24156c7859c530298fad (patch) | |
tree | 8b36782c9bda728c432782829e7e9b236ae6caa0 /lib/httpserver/HTTPRequest.cpp | |
parent | aec3fa23a75124d860f48b9007858ec1cb641623 (diff) |
Move S3Simulator into its own class, like S3Client, for reuse elsewhere.
Diffstat (limited to 'lib/httpserver/HTTPRequest.cpp')
-rw-r--r-- | lib/httpserver/HTTPRequest.cpp | 23 |
1 files changed, 10 insertions, 13 deletions
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)); } |