summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLu <[email protected]>2018-08-16 14:26:32 +0800
committerLu <[email protected]>2018-08-16 14:26:32 +0800
commitd7f21128558e140e68ceb51e63429e95130f9565 (patch)
tree62b021ca2939518f720703f6db3d5a5e63d040b0
parent0185ccff6675752c99a4a03c3d4ff72e18ab306a (diff)
Closed #16develop-tfe2a
-rw-r--r--src/http1.cc23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/http1.cc b/src/http1.cc
index f40aecb..cce147c 100644
--- a/src/http1.cc
+++ b/src/http1.cc
@@ -110,13 +110,34 @@ public:
/* 处理到Value时,Field不应为空
* Value可能分成片段,多次调用给出,在这里需要将他们拼合 */
+ std::string __str_data = std::string(data, data + len);
+
/* Hack, 直接覆盖Accept-Encoding,用空格等长替换 */
if (strcasecmp(str_last_header_field_.c_str(), "Accept-Encoding") == 0)
{
memset((void *) data, 0x20, len);
}
+ else
+ {
+ str_last_value_field_ += __str_data;
+ }
+
+ /* Hack,对于Google.com,在Cookie中嵌有GZ=Z=1字段,表示浏览器支持GZIP,服务端将不遵守Accept-Encoding中的约定,
+ * 需要将Cookie中的这个字段抹去,避免服务端返回GZIP编码的应答 */
+ static const std::string __gz_tag{"GZ=Z=1"};
+ std::string::size_type __find_location;
+
+ if ((strcasecmp(str_last_header_field_.c_str(), "Cookie") == 0) &&
+ ((__find_location = __str_data.rfind(__gz_tag)) != std::string::npos))
+ {
+ auto replace_location = __find_location + __gz_tag.length() - 1;
+ assert(replace_location <= len);
+
+ char * __data = (char *)data;
+ __data[replace_location] = '0';
+ }
- str_last_value_field_ += std::string(data, data + len);
+ return;
}
void ConstructByHttpParserComplete()