mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-13 01:20:22 +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)
|
if (colon != std::string::npos)
|
||||||
{
|
{
|
||||||
std::string field = header.substr (0, colon);
|
std::string field = header.substr (0, colon);
|
||||||
|
boost::to_lower (field); // field are not case-sensitive
|
||||||
colon++;
|
colon++;
|
||||||
header.resize (header.length () - 1); // delete \r
|
header.resize (header.length () - 1); // delete \r
|
||||||
if (field == i2p::util::http::ETAG)
|
if (field == i2p::util::http::ETAG)
|
||||||
@ -567,9 +568,8 @@ namespace client
|
|||||||
else if (field == i2p::util::http::TRANSFER_ENCODING)
|
else if (field == i2p::util::http::TRANSFER_ENCODING)
|
||||||
isChunked = !header.compare (colon + 1, std::string::npos, "chunked");
|
isChunked = !header.compare (colon + 1, std::string::npos, "chunked");
|
||||||
else if (field == i2p::util::http::CONTENT_ENCODING)
|
else if (field == i2p::util::http::CONTENT_ENCODING)
|
||||||
isGzip = !header.compare (colon + 1, std::string::npos, "gzip");
|
isGzip = !header.compare (colon + 1, std::string::npos, "gzip") ||
|
||||||
else if (field == i2p::util::http::CONTENT_ENCODING1) // Content-encoding
|
!header.compare (colon + 1, std::string::npos, "x-i2p-gzip");
|
||||||
isGzip = !header.compare (colon + 1, std::string::npos, "x-i2p-gzip");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LogPrint (eLogInfo, "Addressbook: ", m_Link, " ETag: ", m_Etag, " Last-Modified: ", m_LastModified);
|
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)
|
if (colon != std::string::npos)
|
||||||
{
|
{
|
||||||
std::string field = header.substr (0, colon);
|
std::string field = header.substr (0, colon);
|
||||||
|
boost::to_lower (field);
|
||||||
if (field == i2p::util::http::TRANSFER_ENCODING)
|
if (field == i2p::util::http::TRANSFER_ENCODING)
|
||||||
isChunked = (header.find ("chunked", colon + 1) != std::string::npos);
|
isChunked = (header.find ("chunked", colon + 1) != std::string::npos);
|
||||||
}
|
}
|
||||||
|
15
util.h
15
util.h
@ -29,14 +29,15 @@ namespace util
|
|||||||
|
|
||||||
namespace http
|
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_NONE_MATCH[] = "If-None-Match";
|
||||||
const char IF_MODIFIED_SINCE[] = "If-Modified-Since";
|
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";
|
|
||||||
|
|
||||||
std::string GetHttpContent (std::istream& response);
|
std::string GetHttpContent (std::istream& response);
|
||||||
void MergeChunkedResponse (std::istream& response, std::ostream& merged);
|
void MergeChunkedResponse (std::istream& response, std::ostream& merged);
|
||||||
std::string urlDecode(const std::string& data);
|
std::string urlDecode(const std::string& data);
|
||||||
|
Loading…
Reference in New Issue
Block a user