Browse Source

+ HTTP.{cpp,h} : add HTTPRes::is_gzipped()

pull/574/head
hagen 8 years ago
parent
commit
c4721e1020
  1. 12
      HTTP.cpp
  2. 3
      HTTP.h

12
HTTP.cpp

@ -278,6 +278,18 @@ namespace http { @@ -278,6 +278,18 @@ namespace http {
return false;
}
bool HTTPRes::is_gzipped() {
auto it = headers.find("x-i2p-gzip");
if (it == headers.end())
return true; /* i2p-specific header */
it = headers.find("Content-Encoding");
if (it == headers.end())
return false; /* no header */
if (it->second.find("gzip") != std::string::npos)
return true; /* gotcha! */
return false;
}
long int HTTPMsg::content_length() {
unsigned long int length = 0;
auto it = headers.find("Content-Length");

3
HTTP.h

@ -118,6 +118,9 @@ namespace http { @@ -118,6 +118,9 @@ namespace http {
/** @brief Checks that response declared as chunked data */
bool is_chunked();
/** @brief Checks that response contains compressed data */
bool is_gzipped();
};
/**

Loading…
Cancel
Save