Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(722)

Unified Diff: net/url_request/url_request_http_job_unittest.cc

Issue 2512263002: Pass raw response with Context-Encoding sdch if support is not configured. (Closed)
Patch Set: Fix net unittests. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/url_request/url_request_http_job_unittest.cc
diff --git a/net/url_request/url_request_http_job_unittest.cc b/net/url_request/url_request_http_job_unittest.cc
index a8b3b54af082c37020de267dfd5613ea0911fdf3..8bf2f0cad281e4025cdb3e8adedee336f20e1df0 100644
--- a/net/url_request/url_request_http_job_unittest.cc
+++ b/net/url_request/url_request_http_job_unittest.cc
@@ -184,7 +184,9 @@ TEST_F(URLRequestHttpJobSetUpSourceTest,
request->Start();
base::RunLoop().Run();
- EXPECT_EQ(ERR_CONTENT_DECODING_INIT_FAILED, delegate_.request_status());
+ // Pass through the raw response tje same way as if received unknown encoding.
xunjieli 2016/11/29 23:30:42 nit: typo in "the"
mef 2016/11/30 15:51:07 Done.
+ EXPECT_EQ(OK, delegate_.request_status());
+ EXPECT_EQ("Test Content", delegate_.data_received());
}
class URLRequestHttpJobTest : public ::testing::Test {
@@ -776,6 +778,44 @@ class URLRequestHttpJobWithSdchSupportTest : public ::testing::Test {
TestURLRequestContext context_;
};
+// Received a malformed SDCH encoded response when there is no SdchManager.
xunjieli 2016/11/29 23:30:42 Could you adjust this comment to something like:
mef 2016/11/30 15:51:07 Done.
+TEST_F(URLRequestHttpJobWithSdchSupportTest,
+ SdchAdvertisedGotMalformedSdchResponse) {
+ MockWrite writes[] = {
+ MockWrite("GET / HTTP/1.1\r\n"
+ "Host: www.example.com\r\n"
+ "Connection: keep-alive\r\n"
+ "User-Agent:\r\n"
+ "Accept-Encoding: gzip, deflate, sdch\r\n"
+ "Accept-Language: en-us,fr\r\n\r\n")};
+ MockRead reads[] = {MockRead("HTTP/1.1 200 OK\r\n"
+ "Content-Encoding: sdch\r\n"
+ "Content-Length: 12\r\n\r\n"),
+ MockRead("Test Content")};
+
+ StaticSocketDataProvider socket_data(reads, arraysize(reads), writes,
+ arraysize(writes));
+ socket_factory_.AddSocketDataProvider(&socket_data);
+
+ MockSdchObserver sdch_observer;
+ SdchManager sdch_manager;
+ sdch_manager.AddObserver(&sdch_observer);
+ context_.set_sdch_manager(&sdch_manager);
+ TestDelegate delegate;
+ std::unique_ptr<URLRequest> request = context_.CreateRequest(
+ GURL("http://www.example.com"), DEFAULT_PRIORITY, &delegate);
+ request->Start();
+
+ base::RunLoop().Run();
+ // SDCH encoded content is silently passed through if it cannot be decoded.
+ // EXPECT_EQ(ERR_CONTENT_DECODING_INIT_FAILED, delegate.request_status());
mef 2016/11/29 22:51:51 I would've expected an error if SDCH manager is pr
xunjieli 2016/11/29 23:30:42 This is expected. SdchPolicyDelegate::OnDictionary
mef 2016/11/30 15:51:07 Acknowledged. Thanks for explanation!
+ // Pass through the raw response tje same way as if received unknown encoding.
xunjieli 2016/11/29 23:30:42 Could you remove this line and the line above? May
mef 2016/11/30 15:51:07 Done.
+ EXPECT_EQ(OK, delegate.request_status());
+ EXPECT_EQ("Test Content", delegate.data_received());
+ // Cleanup manager.
+ sdch_manager.RemoveObserver(&sdch_observer);
+}
+
TEST_F(URLRequestHttpJobWithSdchSupportTest, GetDictionary) {
MockWrite writes[] = {
MockWrite("GET / HTTP/1.1\r\n"
« components/cronet/ios/test/cronet_http_test.mm ('K') | « net/url_request/url_request_http_job.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698