OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/url_request/url_request_job.h" | 5 #include "net/url_request/url_request_job.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "net/base/request_priority.h" | 9 #include "net/base/request_priority.h" |
10 #include "net/http/http_transaction_test_util.h" | 10 #include "net/http/http_transaction_test_util.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 base::Time(), | 69 base::Time(), |
70 "hello", | 70 "hello", |
71 TEST_MODE_NORMAL, | 71 TEST_MODE_NORMAL, |
72 nullptr, | 72 nullptr, |
73 nullptr, | 73 nullptr, |
74 0, | 74 0, |
75 0, | 75 0, |
76 OK, | 76 OK, |
77 }; | 77 }; |
78 | 78 |
79 const MockTransaction kEmptyBodyGzip_Transaction = { | |
80 "http://www.google.com/empty_body", | |
81 "GET", | |
82 base::Time(), | |
83 "", | |
84 LOAD_NORMAL, | |
85 "HTTP/1.1 200 OK", | |
86 "Content-Encoding: gzip\n", | |
87 base::Time(), | |
88 "", | |
89 TEST_MODE_NORMAL, | |
90 nullptr, | |
91 nullptr, | |
92 0, | |
93 0, | |
94 OK, | |
95 }; | |
96 | |
97 } // namespace | 79 } // namespace |
98 | 80 |
99 TEST(URLRequestJob, TransactionNotifiedWhenDone) { | 81 TEST(URLRequestJob, TransactionNotifiedWhenDone) { |
100 MockNetworkLayer network_layer; | 82 MockNetworkLayer network_layer; |
101 TestURLRequestContext context; | 83 TestURLRequestContext context; |
102 context.set_http_transaction_factory(&network_layer); | 84 context.set_http_transaction_factory(&network_layer); |
103 | 85 |
104 TestDelegate d; | 86 TestDelegate d; |
105 scoped_ptr<URLRequest> req( | 87 scoped_ptr<URLRequest> req( |
106 context.CreateRequest(GURL(kGZip_Transaction.url), DEFAULT_PRIORITY, &d)); | 88 context.CreateRequest(GURL(kGZip_Transaction.url), DEFAULT_PRIORITY, &d)); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 req->set_method("GET"); | 180 req->set_method("GET"); |
199 req->Start(); | 181 req->Start(); |
200 | 182 |
201 base::RunLoop().Run(); | 183 base::RunLoop().Run(); |
202 | 184 |
203 EXPECT_TRUE(network_layer.stop_caching_called()); | 185 EXPECT_TRUE(network_layer.stop_caching_called()); |
204 | 186 |
205 RemoveMockTransaction(&kGZip_Transaction); | 187 RemoveMockTransaction(&kGZip_Transaction); |
206 } | 188 } |
207 | 189 |
208 // Makes sure that ReadRawDataComplete correctly updates request status before | |
209 // calling ReadFilteredData. | |
210 // Regression test for crbug.com/553300. | |
211 TEST(URLRequestJob, EmptyBodySkipFilter) { | |
212 MockNetworkLayer network_layer; | |
213 TestURLRequestContext context; | |
214 context.set_http_transaction_factory(&network_layer); | |
215 | |
216 TestDelegate d; | |
217 scoped_ptr<URLRequest> req(context.CreateRequest( | |
218 GURL(kEmptyBodyGzip_Transaction.url), DEFAULT_PRIORITY, &d)); | |
219 AddMockTransaction(&kEmptyBodyGzip_Transaction); | |
220 | |
221 req->set_method("GET"); | |
222 req->Start(); | |
223 | |
224 base::MessageLoop::current()->Run(); | |
225 | |
226 EXPECT_FALSE(d.request_failed()); | |
227 EXPECT_EQ(200, req->GetResponseCode()); | |
228 EXPECT_TRUE(d.data_received().empty()); | |
229 EXPECT_TRUE(network_layer.done_reading_called()); | |
230 | |
231 RemoveMockTransaction(&kEmptyBodyGzip_Transaction); | |
232 } | |
233 | |
234 } // namespace net | 190 } // namespace net |
OLD | NEW |