mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-10 00:00:29 +03:00
case-insensitive http responses
This commit is contained in:
parent
f1d4818045
commit
c5b6da7201
@ -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
|
||||
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
1
util.cpp
@ -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
15
util.h
@ -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…
Reference in New Issue
Block a user