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

Unified Diff: net/url_request/url_request_job_unittest.cc

Issue 267793002: net: Avoid recursion in URLRequestJob::ReadFilteredData. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 6 years, 8 months 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
« no previous file with comments | « net/url_request/url_request_job.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/url_request/url_request_job_unittest.cc
diff --git a/net/url_request/url_request_job_unittest.cc b/net/url_request/url_request_job_unittest.cc
index c8bbc1903894bfdd68aa93ae4288f17bf6f99896..d90fc9b8be172fe9bb453d877168496865ea97f3 100644
--- a/net/url_request/url_request_job_unittest.cc
+++ b/net/url_request/url_request_job_unittest.cc
@@ -15,13 +15,23 @@ namespace net {
namespace {
// This is a header that signals the end of the data.
-const char kGzipGata[] = "\x1f\x08b\x08\0\0\0\0\0\0\3\3\0\0\0\0\0\0\0\0";
+const char kGzipData[] = "\x1f\x08b\x08\0\0\0\0\0\0\3\3\0\0\0\0\0\0\0\0";
+const char kGzipDataWithName[] =
+ "\x1f\x08b\x08\x08\0\0\0\0\0\0name\0\3\0\0\0\0\0\0\0\0";
void GZipServer(const HttpRequestInfo* request,
std::string* response_status,
std::string* response_headers,
std::string* response_data) {
- response_data->assign(kGzipGata, sizeof(kGzipGata));
+ response_data->assign(kGzipData, sizeof(kGzipData));
+}
+
+void BigGZipServer(const HttpRequestInfo* request,
+ std::string* response_status,
+ std::string* response_headers,
+ std::string* response_data) {
+ response_data->assign(kGzipDataWithName, sizeof(kGzipDataWithName));
+ response_data->insert(10, 64 * 1024, 'a');
}
const MockTransaction kGZip_Transaction = {
@@ -104,6 +114,30 @@ TEST(URLRequestJob, SyncTransactionNotifiedWhenDone) {
RemoveMockTransaction(&transaction);
}
+// Tests processing a large gzip header one byte at a time.
+TEST(URLRequestJob, SyncSlowTransaction) {
+ MockNetworkLayer network_layer;
+ TestURLRequestContext context;
+ context.set_http_transaction_factory(&network_layer);
+
+ TestDelegate d;
+ TestURLRequest req(
+ GURL(kGZip_Transaction.url), DEFAULT_PRIORITY, &d, &context);
+ MockTransaction transaction(kGZip_Transaction);
+ transaction.test_mode = TEST_MODE_SYNC_ALL | TEST_MODE_SLOW_READ;
+ transaction.handler = &BigGZipServer;
+ AddMockTransaction(&transaction);
+
+ req.set_method("GET");
+ req.Start();
+
+ base::RunLoop().Run();
+
+ EXPECT_TRUE(network_layer.done_reading_called());
+
+ RemoveMockTransaction(&transaction);
+}
+
TEST(URLRequestJob, RedirectTransactionNotifiedWhenDone) {
MockNetworkLayer network_layer;
TestURLRequestContext context;
« no previous file with comments | « net/url_request/url_request_job.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698