Browse Source

case-insensitive http responses

pull/386/head
orignal 8 years ago
parent
commit
c5b6da7201
  1. 6
      AddressBook.cpp
  2. 1
      util.cpp
  3. 15
      util.h

6
AddressBook.cpp

@ -558,6 +558,7 @@ namespace client @@ -558,6 +558,7 @@ namespace client
if (colon != std::string::npos)
{
std::string field = header.substr (0, colon);
boost::to_lower (field); // field are not case-sensitive
colon++;
header.resize (header.length () - 1); // delete \r
if (field == i2p::util::http::ETAG)
@ -567,9 +568,8 @@ namespace client @@ -567,9 +568,8 @@ namespace client
else if (field == i2p::util::http::TRANSFER_ENCODING)
isChunked = !header.compare (colon + 1, std::string::npos, "chunked");
else if (field == i2p::util::http::CONTENT_ENCODING)
isGzip = !header.compare (colon + 1, std::string::npos, "gzip");
else if (field == i2p::util::http::CONTENT_ENCODING1) // Content-encoding
isGzip = !header.compare (colon + 1, std::string::npos, "x-i2p-gzip");
isGzip = !header.compare (colon + 1, std::string::npos, "gzip") ||
!header.compare (colon + 1, std::string::npos, "x-i2p-gzip");
}
}
LogPrint (eLogInfo, "Addressbook: ", m_Link, " ETag: ", m_Etag, " Last-Modified: ", m_LastModified);

1
util.cpp

@ -212,6 +212,7 @@ namespace http @@ -212,6 +212,7 @@ namespace http
if (colon != std::string::npos)
{
std::string field = header.substr (0, colon);
boost::to_lower (field);
if (field == i2p::util::http::TRANSFER_ENCODING)
isChunked = (header.find ("chunked", colon + 1) != std::string::npos);
}

15
util.h

@ -29,14 +29,15 @@ namespace util @@ -29,14 +29,15 @@ namespace util
namespace http
{
const char ETAG[] = "ETag";
// in (lower case)
const char ETAG[] = "etag"; // ETag
const char LAST_MODIFIED[] = "last-modified"; // Last-Modified
const char TRANSFER_ENCODING[] = "transfer-encoding"; // Transfer-Encoding
const char CONTENT_ENCODING[] = "content-encoding"; // Content-Encoding
// out
const char IF_NONE_MATCH[] = "If-None-Match";
const char IF_MODIFIED_SINCE[] = "If-Modified-Since";
const char LAST_MODIFIED[] = "Last-Modified";
const char TRANSFER_ENCODING[] = "Transfer-Encoding";
const char CONTENT_ENCODING[] = "Content-Encoding";
const char CONTENT_ENCODING1[] = "Content-encoding";
const char IF_MODIFIED_SINCE[] = "If-Modified-Since";
std::string GetHttpContent (std::istream& response);
void MergeChunkedResponse (std::istream& response, std::ostream& merged);
std::string urlDecode(const std::string& data);

Loading…
Cancel
Save