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; |