mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-10 00:00:29 +03:00
enable i2p gzip compression
This commit is contained in:
parent
47bf0ef591
commit
3053a9b6a0
@ -508,6 +508,7 @@ namespace client
|
||||
<< "Accept: */*\r\n"
|
||||
<< "User-Agent: Wget/1.11.4\r\n"
|
||||
//<< "Accept-Encoding: gzip\r\n"
|
||||
<< "X-Accept-Encoding: x-i2p-gzip;q=1.0, identity;q=0.5, deflate;q=0, gzip;q=0, *;q=0\r\n"
|
||||
<< "Connection: close\r\n";
|
||||
if (m_Etag.length () > 0) // etag
|
||||
request << i2p::util::http::IF_NONE_MATCH << ": \"" << m_Etag << "\"\r\n";
|
||||
@ -557,6 +558,7 @@ namespace client
|
||||
if (colon != std::string::npos)
|
||||
{
|
||||
std::string field = header.substr (0, colon);
|
||||
colon++;
|
||||
header.resize (header.length () - 1); // delete \r
|
||||
if (field == i2p::util::http::ETAG)
|
||||
m_Etag = header.substr (colon + 1);
|
||||
@ -566,6 +568,8 @@ namespace client
|
||||
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");
|
||||
}
|
||||
}
|
||||
LogPrint (eLogInfo, "Addressbook: ", m_Link, " ETag: ", m_Etag, " Last-Modified: ", m_LastModified);
|
||||
|
5
Base.cpp
5
Base.cpp
@ -329,9 +329,10 @@ namespace data
|
||||
return ret == Z_STREAM_END || ret < 0;
|
||||
}
|
||||
|
||||
void GzipInflator::Inflate (const std::stringstream& in, std::ostream& out)
|
||||
void GzipInflator::Inflate (std::stringstream& in, std::ostream& out)
|
||||
{
|
||||
Inflate ((const uint8_t *)in.str ().c_str (), in.str ().length (), out);
|
||||
auto str = in.str ().substr (in.tellg ());
|
||||
Inflate ((const uint8_t *)str.c_str (), str.length (), out);
|
||||
}
|
||||
|
||||
GzipDeflator::GzipDeflator (): m_IsDirty (false)
|
||||
|
2
Base.h
2
Base.h
@ -105,7 +105,7 @@ namespace data
|
||||
size_t Inflate (const uint8_t * in, size_t inLen, uint8_t * out, size_t outLen);
|
||||
bool Inflate (const uint8_t * in, size_t inLen, std::ostream& s);
|
||||
// return true when finshed or error, s failbit will be set in case of error
|
||||
void Inflate (const std::stringstream& in, std::ostream& out);
|
||||
void Inflate (std::stringstream& in, std::ostream& out);
|
||||
|
||||
private:
|
||||
|
||||
|
3
util.h
3
util.h
@ -35,7 +35,8 @@ namespace util
|
||||
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);
|
||||
void MergeChunkedResponse (std::istream& response, std::ostream& merged);
|
||||
std::string urlDecode(const std::string& data);
|
||||
|
Loading…
Reference in New Issue
Block a user