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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
8 #include "base/memory/scoped_vector.h" | 8 #include "base/memory/scoped_vector.h" |
9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 scoped_refptr<SSLConfigService> ssl_config_; | 185 scoped_refptr<SSLConfigService> ssl_config_; |
186 scoped_ptr<HttpAuthHandlerMock::Factory> auth_handler_factory_; | 186 scoped_ptr<HttpAuthHandlerMock::Factory> auth_handler_factory_; |
187 HttpServerPropertiesImpl http_server_properties_; | 187 HttpServerPropertiesImpl http_server_properties_; |
188 scoped_refptr<HttpNetworkSession> session_; | 188 scoped_refptr<HttpNetworkSession> session_; |
189 }; | 189 }; |
190 | 190 |
191 TEST_F(HttpPipelinedNetworkTransactionTest, OneRequest) { | 191 TEST_F(HttpPipelinedNetworkTransactionTest, OneRequest) { |
192 Initialize(); | 192 Initialize(); |
193 | 193 |
194 MockWrite writes[] = { | 194 MockWrite writes[] = { |
195 MockWrite(false, 0, "GET /test.html HTTP/1.1\r\n" | 195 MockWrite(SYNCHRONOUS, 0, "GET /test.html HTTP/1.1\r\n" |
196 "Host: localhost\r\n" | 196 "Host: localhost\r\n" |
197 "Connection: keep-alive\r\n\r\n"), | 197 "Connection: keep-alive\r\n\r\n"), |
198 }; | 198 }; |
199 MockRead reads[] = { | 199 MockRead reads[] = { |
200 MockRead(false, 1, "HTTP/1.1 200 OK\r\n"), | 200 MockRead(SYNCHRONOUS, 1, "HTTP/1.1 200 OK\r\n"), |
201 MockRead(false, 2, "Content-Length: 9\r\n\r\n"), | 201 MockRead(SYNCHRONOUS, 2, "Content-Length: 9\r\n\r\n"), |
202 MockRead(false, 3, "test.html"), | 202 MockRead(SYNCHRONOUS, 3, "test.html"), |
203 }; | 203 }; |
204 AddExpectedConnection(reads, arraysize(reads), writes, arraysize(writes)); | 204 AddExpectedConnection(reads, arraysize(reads), writes, arraysize(writes)); |
205 | 205 |
206 HttpNetworkTransaction transaction(session_.get()); | 206 HttpNetworkTransaction transaction(session_.get()); |
207 EXPECT_EQ(ERR_IO_PENDING, | 207 EXPECT_EQ(ERR_IO_PENDING, |
208 transaction.Start(GetRequestInfo("test.html"), callback_.callback(), | 208 transaction.Start(GetRequestInfo("test.html"), callback_.callback(), |
209 BoundNetLog())); | 209 BoundNetLog())); |
210 EXPECT_EQ(OK, callback_.WaitForResult()); | 210 EXPECT_EQ(OK, callback_.WaitForResult()); |
211 ExpectResponse("test.html", transaction); | 211 ExpectResponse("test.html", transaction); |
212 } | 212 } |
213 | 213 |
214 TEST_F(HttpPipelinedNetworkTransactionTest, ReusePipeline) { | 214 TEST_F(HttpPipelinedNetworkTransactionTest, ReusePipeline) { |
215 Initialize(); | 215 Initialize(); |
216 | 216 |
217 MockWrite writes[] = { | 217 MockWrite writes[] = { |
218 MockWrite(false, 0, "GET /one.html HTTP/1.1\r\n" | 218 MockWrite(SYNCHRONOUS, 0, "GET /one.html HTTP/1.1\r\n" |
219 "Host: localhost\r\n" | 219 "Host: localhost\r\n" |
220 "Connection: keep-alive\r\n\r\n"), | 220 "Connection: keep-alive\r\n\r\n"), |
221 MockWrite(false, 3, "GET /two.html HTTP/1.1\r\n" | 221 MockWrite(SYNCHRONOUS, 3, "GET /two.html HTTP/1.1\r\n" |
222 "Host: localhost\r\n" | 222 "Host: localhost\r\n" |
223 "Connection: keep-alive\r\n\r\n"), | 223 "Connection: keep-alive\r\n\r\n"), |
224 }; | 224 }; |
225 MockRead reads[] = { | 225 MockRead reads[] = { |
226 MockRead(false, 1, "HTTP/1.1 200 OK\r\n"), | 226 MockRead(SYNCHRONOUS, 1, "HTTP/1.1 200 OK\r\n"), |
227 MockRead(false, 2, "Content-Length: 8\r\n\r\n"), | 227 MockRead(SYNCHRONOUS, 2, "Content-Length: 8\r\n\r\n"), |
228 MockRead(true, 4, "one.html"), | 228 MockRead(ASYNC, 4, "one.html"), |
229 MockRead(false, 5, "HTTP/1.1 200 OK\r\n"), | 229 MockRead(SYNCHRONOUS, 5, "HTTP/1.1 200 OK\r\n"), |
230 MockRead(false, 6, "Content-Length: 8\r\n\r\n"), | 230 MockRead(SYNCHRONOUS, 6, "Content-Length: 8\r\n\r\n"), |
231 MockRead(false, 7, "two.html"), | 231 MockRead(SYNCHRONOUS, 7, "two.html"), |
232 }; | 232 }; |
233 AddExpectedConnection(reads, arraysize(reads), writes, arraysize(writes)); | 233 AddExpectedConnection(reads, arraysize(reads), writes, arraysize(writes)); |
234 | 234 |
235 CompleteTwoRequests(0, 5); | 235 CompleteTwoRequests(0, 5); |
236 } | 236 } |
237 | 237 |
238 TEST_F(HttpPipelinedNetworkTransactionTest, ReusesOnSpaceAvailable) { | 238 TEST_F(HttpPipelinedNetworkTransactionTest, ReusesOnSpaceAvailable) { |
239 int old_max_sockets = ClientSocketPoolManager::max_sockets_per_group(); | 239 int old_max_sockets = ClientSocketPoolManager::max_sockets_per_group(); |
240 ClientSocketPoolManager::set_max_sockets_per_group(1); | 240 ClientSocketPoolManager::set_max_sockets_per_group(1); |
241 Initialize(); | 241 Initialize(); |
242 | 242 |
243 MockWrite writes[] = { | 243 MockWrite writes[] = { |
244 MockWrite(false, 0, "GET /one.html HTTP/1.1\r\n" | 244 MockWrite(SYNCHRONOUS, 0, "GET /one.html HTTP/1.1\r\n" |
245 "Host: localhost\r\n" | 245 "Host: localhost\r\n" |
246 "Connection: keep-alive\r\n\r\n"), | 246 "Connection: keep-alive\r\n\r\n"), |
247 MockWrite(false, 4, "GET /two.html HTTP/1.1\r\n" | 247 MockWrite(SYNCHRONOUS, 4, "GET /two.html HTTP/1.1\r\n" |
248 "Host: localhost\r\n" | 248 "Host: localhost\r\n" |
249 "Connection: keep-alive\r\n\r\n"), | 249 "Connection: keep-alive\r\n\r\n"), |
250 MockWrite(false, 7, "GET /three.html HTTP/1.1\r\n" | 250 MockWrite(SYNCHRONOUS, 7, "GET /three.html HTTP/1.1\r\n" |
251 "Host: localhost\r\n" | 251 "Host: localhost\r\n" |
252 "Connection: keep-alive\r\n\r\n"), | 252 "Connection: keep-alive\r\n\r\n"), |
253 MockWrite(false, 12, "GET /four.html HTTP/1.1\r\n" | 253 MockWrite(SYNCHRONOUS, 12, "GET /four.html HTTP/1.1\r\n" |
254 "Host: localhost\r\n" | 254 "Host: localhost\r\n" |
255 "Connection: keep-alive\r\n\r\n"), | 255 "Connection: keep-alive\r\n\r\n"), |
256 }; | 256 }; |
257 MockRead reads[] = { | 257 MockRead reads[] = { |
258 MockRead(false, 1, "HTTP/1.1 200 OK\r\n"), | 258 MockRead(SYNCHRONOUS, 1, "HTTP/1.1 200 OK\r\n"), |
259 MockRead(false, 2, "Content-Length: 8\r\n\r\n"), | 259 MockRead(SYNCHRONOUS, 2, "Content-Length: 8\r\n\r\n"), |
260 MockRead(false, 3, "one.html"), | 260 MockRead(SYNCHRONOUS, 3, "one.html"), |
261 MockRead(false, 5, "HTTP/1.1 200 OK\r\n"), | 261 MockRead(SYNCHRONOUS, 5, "HTTP/1.1 200 OK\r\n"), |
262 MockRead(false, 6, "Content-Length: 8\r\n\r\n"), | 262 MockRead(SYNCHRONOUS, 6, "Content-Length: 8\r\n\r\n"), |
263 MockRead(false, 8, "two.html"), | 263 MockRead(SYNCHRONOUS, 8, "two.html"), |
264 MockRead(false, 9, "HTTP/1.1 200 OK\r\n"), | 264 MockRead(SYNCHRONOUS, 9, "HTTP/1.1 200 OK\r\n"), |
265 MockRead(false, 10, "Content-Length: 10\r\n\r\n"), | 265 MockRead(SYNCHRONOUS, 10, "Content-Length: 10\r\n\r\n"), |
266 MockRead(false, 11, "three.html"), | 266 MockRead(SYNCHRONOUS, 11, "three.html"), |
267 MockRead(false, 13, "HTTP/1.1 200 OK\r\n"), | 267 MockRead(SYNCHRONOUS, 13, "HTTP/1.1 200 OK\r\n"), |
268 MockRead(false, 14, "Content-Length: 9\r\n\r\n"), | 268 MockRead(SYNCHRONOUS, 14, "Content-Length: 9\r\n\r\n"), |
269 MockRead(false, 15, "four.html"), | 269 MockRead(SYNCHRONOUS, 15, "four.html"), |
270 }; | 270 }; |
271 AddExpectedConnection(reads, arraysize(reads), writes, arraysize(writes)); | 271 AddExpectedConnection(reads, arraysize(reads), writes, arraysize(writes)); |
272 | 272 |
273 CompleteFourRequests(); | 273 CompleteFourRequests(); |
274 | 274 |
275 ClientSocketPoolManager::set_max_sockets_per_group(old_max_sockets); | 275 ClientSocketPoolManager::set_max_sockets_per_group(old_max_sockets); |
276 } | 276 } |
277 | 277 |
278 TEST_F(HttpPipelinedNetworkTransactionTest, UnknownSizeEvictsToNewPipeline) { | 278 TEST_F(HttpPipelinedNetworkTransactionTest, UnknownSizeEvictsToNewPipeline) { |
279 Initialize(); | 279 Initialize(); |
280 | 280 |
281 MockWrite writes[] = { | 281 MockWrite writes[] = { |
282 MockWrite(false, 0, "GET /one.html HTTP/1.1\r\n" | 282 MockWrite(SYNCHRONOUS, 0, "GET /one.html HTTP/1.1\r\n" |
283 "Host: localhost\r\n" | 283 "Host: localhost\r\n" |
284 "Connection: keep-alive\r\n\r\n"), | 284 "Connection: keep-alive\r\n\r\n"), |
285 }; | 285 }; |
286 MockRead reads[] = { | 286 MockRead reads[] = { |
287 MockRead(false, 1, "HTTP/1.1 200 OK\r\n\r\n"), | 287 MockRead(SYNCHRONOUS, 1, "HTTP/1.1 200 OK\r\n\r\n"), |
288 MockRead(true, 2, "one.html"), | 288 MockRead(ASYNC, 2, "one.html"), |
289 MockRead(false, OK, 3), | 289 MockRead(SYNCHRONOUS, OK, 3), |
290 }; | 290 }; |
291 AddExpectedConnection(reads, arraysize(reads), writes, arraysize(writes)); | 291 AddExpectedConnection(reads, arraysize(reads), writes, arraysize(writes)); |
292 | 292 |
293 MockWrite writes2[] = { | 293 MockWrite writes2[] = { |
294 MockWrite(false, 0, "GET /two.html HTTP/1.1\r\n" | 294 MockWrite(SYNCHRONOUS, 0, "GET /two.html HTTP/1.1\r\n" |
295 "Host: localhost\r\n" | 295 "Host: localhost\r\n" |
296 "Connection: keep-alive\r\n\r\n"), | 296 "Connection: keep-alive\r\n\r\n"), |
297 }; | 297 }; |
298 MockRead reads2[] = { | 298 MockRead reads2[] = { |
299 MockRead(false, 1, "HTTP/1.1 200 OK\r\n"), | 299 MockRead(SYNCHRONOUS, 1, "HTTP/1.1 200 OK\r\n"), |
300 MockRead(false, 2, "Content-Length: 8\r\n\r\n"), | 300 MockRead(SYNCHRONOUS, 2, "Content-Length: 8\r\n\r\n"), |
301 MockRead(false, 3, "two.html"), | 301 MockRead(SYNCHRONOUS, 3, "two.html"), |
302 }; | 302 }; |
303 AddExpectedConnection(reads2, arraysize(reads2), writes2, arraysize(writes2)); | 303 AddExpectedConnection(reads2, arraysize(reads2), writes2, arraysize(writes2)); |
304 | 304 |
305 CompleteTwoRequests(0, 3); | 305 CompleteTwoRequests(0, 3); |
306 } | 306 } |
307 | 307 |
308 TEST_F(HttpPipelinedNetworkTransactionTest, ConnectionCloseEvictToNewPipeline) { | 308 TEST_F(HttpPipelinedNetworkTransactionTest, ConnectionCloseEvictToNewPipeline) { |
309 Initialize(); | 309 Initialize(); |
310 | 310 |
311 MockWrite writes[] = { | 311 MockWrite writes[] = { |
312 MockWrite(false, 0, "GET /one.html HTTP/1.1\r\n" | 312 MockWrite(SYNCHRONOUS, 0, "GET /one.html HTTP/1.1\r\n" |
313 "Host: localhost\r\n" | 313 "Host: localhost\r\n" |
314 "Connection: keep-alive\r\n\r\n"), | 314 "Connection: keep-alive\r\n\r\n"), |
315 MockWrite(false, 3, "GET /two.html HTTP/1.1\r\n" | 315 MockWrite(SYNCHRONOUS, 3, "GET /two.html HTTP/1.1\r\n" |
316 "Host: localhost\r\n" | 316 "Host: localhost\r\n" |
317 "Connection: keep-alive\r\n\r\n"), | 317 "Connection: keep-alive\r\n\r\n"), |
318 }; | 318 }; |
319 MockRead reads[] = { | 319 MockRead reads[] = { |
320 MockRead(false, 1, "HTTP/1.1 200 OK\r\n"), | 320 MockRead(SYNCHRONOUS, 1, "HTTP/1.1 200 OK\r\n"), |
321 MockRead(false, 2, "Content-Length: 8\r\n\r\n"), | 321 MockRead(SYNCHRONOUS, 2, "Content-Length: 8\r\n\r\n"), |
322 MockRead(true, 4, "one.html"), | 322 MockRead(ASYNC, 4, "one.html"), |
323 MockRead(false, ERR_SOCKET_NOT_CONNECTED, 5), | 323 MockRead(SYNCHRONOUS, ERR_SOCKET_NOT_CONNECTED, 5), |
324 }; | 324 }; |
325 AddExpectedConnection(reads, arraysize(reads), writes, arraysize(writes)); | 325 AddExpectedConnection(reads, arraysize(reads), writes, arraysize(writes)); |
326 | 326 |
327 MockWrite writes2[] = { | 327 MockWrite writes2[] = { |
328 MockWrite(false, 0, "GET /two.html HTTP/1.1\r\n" | 328 MockWrite(SYNCHRONOUS, 0, "GET /two.html HTTP/1.1\r\n" |
329 "Host: localhost\r\n" | 329 "Host: localhost\r\n" |
330 "Connection: keep-alive\r\n\r\n"), | 330 "Connection: keep-alive\r\n\r\n"), |
331 }; | 331 }; |
332 MockRead reads2[] = { | 332 MockRead reads2[] = { |
333 MockRead(false, 1, "HTTP/1.1 200 OK\r\n"), | 333 MockRead(SYNCHRONOUS, 1, "HTTP/1.1 200 OK\r\n"), |
334 MockRead(false, 2, "Content-Length: 8\r\n\r\n"), | 334 MockRead(SYNCHRONOUS, 2, "Content-Length: 8\r\n\r\n"), |
335 MockRead(false, 3, "two.html"), | 335 MockRead(SYNCHRONOUS, 3, "two.html"), |
336 }; | 336 }; |
337 AddExpectedConnection(reads2, arraysize(reads2), writes2, arraysize(writes2)); | 337 AddExpectedConnection(reads2, arraysize(reads2), writes2, arraysize(writes2)); |
338 | 338 |
339 CompleteTwoRequests(0, 5); | 339 CompleteTwoRequests(0, 5); |
340 } | 340 } |
341 | 341 |
342 TEST_F(HttpPipelinedNetworkTransactionTest, ErrorEvictsToNewPipeline) { | 342 TEST_F(HttpPipelinedNetworkTransactionTest, ErrorEvictsToNewPipeline) { |
343 Initialize(); | 343 Initialize(); |
344 | 344 |
345 MockWrite writes[] = { | 345 MockWrite writes[] = { |
346 MockWrite(false, 0, "GET /one.html HTTP/1.1\r\n" | 346 MockWrite(SYNCHRONOUS, 0, "GET /one.html HTTP/1.1\r\n" |
347 "Host: localhost\r\n" | 347 "Host: localhost\r\n" |
348 "Connection: keep-alive\r\n\r\n"), | 348 "Connection: keep-alive\r\n\r\n"), |
349 MockWrite(false, 3, "GET /two.html HTTP/1.1\r\n" | 349 MockWrite(SYNCHRONOUS, 3, "GET /two.html HTTP/1.1\r\n" |
350 "Host: localhost\r\n" | 350 "Host: localhost\r\n" |
351 "Connection: keep-alive\r\n\r\n"), | 351 "Connection: keep-alive\r\n\r\n"), |
352 }; | 352 }; |
353 MockRead reads[] = { | 353 MockRead reads[] = { |
354 MockRead(false, 1, "HTTP/1.1 200 OK\r\n\r\n"), | 354 MockRead(SYNCHRONOUS, 1, "HTTP/1.1 200 OK\r\n\r\n"), |
355 MockRead(false, ERR_FAILED, 2), | 355 MockRead(SYNCHRONOUS, ERR_FAILED, 2), |
356 }; | 356 }; |
357 AddExpectedConnection(reads, arraysize(reads), writes, arraysize(writes)); | 357 AddExpectedConnection(reads, arraysize(reads), writes, arraysize(writes)); |
358 | 358 |
359 MockWrite writes2[] = { | 359 MockWrite writes2[] = { |
360 MockWrite(false, 0, "GET /two.html HTTP/1.1\r\n" | 360 MockWrite(SYNCHRONOUS, 0, "GET /two.html HTTP/1.1\r\n" |
361 "Host: localhost\r\n" | 361 "Host: localhost\r\n" |
362 "Connection: keep-alive\r\n\r\n"), | 362 "Connection: keep-alive\r\n\r\n"), |
363 }; | 363 }; |
364 MockRead reads2[] = { | 364 MockRead reads2[] = { |
365 MockRead(false, 1, "HTTP/1.1 200 OK\r\n"), | 365 MockRead(SYNCHRONOUS, 1, "HTTP/1.1 200 OK\r\n"), |
366 MockRead(false, 2, "Content-Length: 8\r\n\r\n"), | 366 MockRead(SYNCHRONOUS, 2, "Content-Length: 8\r\n\r\n"), |
367 MockRead(false, 3, "two.html"), | 367 MockRead(SYNCHRONOUS, 3, "two.html"), |
368 }; | 368 }; |
369 AddExpectedConnection(reads2, arraysize(reads2), writes2, arraysize(writes2)); | 369 AddExpectedConnection(reads2, arraysize(reads2), writes2, arraysize(writes2)); |
370 | 370 |
371 HttpNetworkTransaction one_transaction(session_.get()); | 371 HttpNetworkTransaction one_transaction(session_.get()); |
372 TestCompletionCallback one_callback; | 372 TestCompletionCallback one_callback; |
373 EXPECT_EQ(ERR_IO_PENDING, | 373 EXPECT_EQ(ERR_IO_PENDING, |
374 one_transaction.Start(GetRequestInfo("one.html"), | 374 one_transaction.Start(GetRequestInfo("one.html"), |
375 one_callback.callback(), BoundNetLog())); | 375 one_callback.callback(), BoundNetLog())); |
376 EXPECT_EQ(OK, one_callback.WaitForResult()); | 376 EXPECT_EQ(OK, one_callback.WaitForResult()); |
377 | 377 |
378 HttpNetworkTransaction two_transaction(session_.get()); | 378 HttpNetworkTransaction two_transaction(session_.get()); |
379 TestCompletionCallback two_callback; | 379 TestCompletionCallback two_callback; |
380 EXPECT_EQ(ERR_IO_PENDING, | 380 EXPECT_EQ(ERR_IO_PENDING, |
381 two_transaction.Start(GetRequestInfo("two.html"), | 381 two_transaction.Start(GetRequestInfo("two.html"), |
382 two_callback.callback(), BoundNetLog())); | 382 two_callback.callback(), BoundNetLog())); |
383 | 383 |
384 scoped_refptr<IOBuffer> buffer(new IOBuffer(1)); | 384 scoped_refptr<IOBuffer> buffer(new IOBuffer(1)); |
385 EXPECT_EQ(ERR_FAILED, | 385 EXPECT_EQ(ERR_FAILED, |
386 one_transaction.Read(buffer.get(), 1, callback_.callback())); | 386 one_transaction.Read(buffer.get(), 1, callback_.callback())); |
387 EXPECT_EQ(OK, two_callback.WaitForResult()); | 387 EXPECT_EQ(OK, two_callback.WaitForResult()); |
388 ExpectResponse("two.html", two_transaction); | 388 ExpectResponse("two.html", two_transaction); |
389 } | 389 } |
390 | 390 |
391 TEST_F(HttpPipelinedNetworkTransactionTest, SendErrorEvictsToNewPipeline) { | 391 TEST_F(HttpPipelinedNetworkTransactionTest, SendErrorEvictsToNewPipeline) { |
392 Initialize(); | 392 Initialize(); |
393 | 393 |
394 MockWrite writes[] = { | 394 MockWrite writes[] = { |
395 MockWrite(true, ERR_FAILED, 0), | 395 MockWrite(ASYNC, ERR_FAILED, 0), |
396 }; | 396 }; |
397 AddExpectedConnection(NULL, 0, writes, arraysize(writes)); | 397 AddExpectedConnection(NULL, 0, writes, arraysize(writes)); |
398 | 398 |
399 MockWrite writes2[] = { | 399 MockWrite writes2[] = { |
400 MockWrite(false, 0, "GET /two.html HTTP/1.1\r\n" | 400 MockWrite(SYNCHRONOUS, 0, "GET /two.html HTTP/1.1\r\n" |
401 "Host: localhost\r\n" | 401 "Host: localhost\r\n" |
402 "Connection: keep-alive\r\n\r\n"), | 402 "Connection: keep-alive\r\n\r\n"), |
403 }; | 403 }; |
404 MockRead reads2[] = { | 404 MockRead reads2[] = { |
405 MockRead(false, 1, "HTTP/1.1 200 OK\r\n"), | 405 MockRead(SYNCHRONOUS, 1, "HTTP/1.1 200 OK\r\n"), |
406 MockRead(false, 2, "Content-Length: 8\r\n\r\n"), | 406 MockRead(SYNCHRONOUS, 2, "Content-Length: 8\r\n\r\n"), |
407 MockRead(false, 3, "two.html"), | 407 MockRead(SYNCHRONOUS, 3, "two.html"), |
408 }; | 408 }; |
409 AddExpectedConnection(reads2, arraysize(reads2), writes2, arraysize(writes2)); | 409 AddExpectedConnection(reads2, arraysize(reads2), writes2, arraysize(writes2)); |
410 | 410 |
411 HttpNetworkTransaction one_transaction(session_.get()); | 411 HttpNetworkTransaction one_transaction(session_.get()); |
412 TestCompletionCallback one_callback; | 412 TestCompletionCallback one_callback; |
413 EXPECT_EQ(ERR_IO_PENDING, | 413 EXPECT_EQ(ERR_IO_PENDING, |
414 one_transaction.Start(GetRequestInfo("one.html"), | 414 one_transaction.Start(GetRequestInfo("one.html"), |
415 one_callback.callback(), BoundNetLog())); | 415 one_callback.callback(), BoundNetLog())); |
416 | 416 |
417 HttpNetworkTransaction two_transaction(session_.get()); | 417 HttpNetworkTransaction two_transaction(session_.get()); |
418 TestCompletionCallback two_callback; | 418 TestCompletionCallback two_callback; |
419 EXPECT_EQ(ERR_IO_PENDING, | 419 EXPECT_EQ(ERR_IO_PENDING, |
420 two_transaction.Start(GetRequestInfo("two.html"), | 420 two_transaction.Start(GetRequestInfo("two.html"), |
421 two_callback.callback(), BoundNetLog())); | 421 two_callback.callback(), BoundNetLog())); |
422 | 422 |
423 data_vector_[0]->RunFor(1); | 423 data_vector_[0]->RunFor(1); |
424 EXPECT_EQ(ERR_FAILED, one_callback.WaitForResult()); | 424 EXPECT_EQ(ERR_FAILED, one_callback.WaitForResult()); |
425 | 425 |
426 EXPECT_EQ(OK, two_callback.WaitForResult()); | 426 EXPECT_EQ(OK, two_callback.WaitForResult()); |
427 ExpectResponse("two.html", two_transaction); | 427 ExpectResponse("two.html", two_transaction); |
428 } | 428 } |
429 | 429 |
430 TEST_F(HttpPipelinedNetworkTransactionTest, RedirectDrained) { | 430 TEST_F(HttpPipelinedNetworkTransactionTest, RedirectDrained) { |
431 Initialize(); | 431 Initialize(); |
432 | 432 |
433 MockWrite writes[] = { | 433 MockWrite writes[] = { |
434 MockWrite(false, 0, "GET /redirect.html HTTP/1.1\r\n" | 434 MockWrite(SYNCHRONOUS, 0, "GET /redirect.html HTTP/1.1\r\n" |
435 "Host: localhost\r\n" | 435 "Host: localhost\r\n" |
436 "Connection: keep-alive\r\n\r\n"), | 436 "Connection: keep-alive\r\n\r\n"), |
437 MockWrite(false, 3, "GET /two.html HTTP/1.1\r\n" | 437 MockWrite(SYNCHRONOUS, 3, "GET /two.html HTTP/1.1\r\n" |
438 "Host: localhost\r\n" | 438 "Host: localhost\r\n" |
439 "Connection: keep-alive\r\n\r\n"), | 439 "Connection: keep-alive\r\n\r\n"), |
440 }; | 440 }; |
441 MockRead reads[] = { | 441 MockRead reads[] = { |
442 MockRead(false, 1, "HTTP/1.1 302 OK\r\n"), | 442 MockRead(SYNCHRONOUS, 1, "HTTP/1.1 302 OK\r\n"), |
443 MockRead(false, 2, "Content-Length: 8\r\n\r\n"), | 443 MockRead(SYNCHRONOUS, 2, "Content-Length: 8\r\n\r\n"), |
444 MockRead(true, 4, "redirect"), | 444 MockRead(ASYNC, 4, "redirect"), |
445 MockRead(false, 5, "HTTP/1.1 200 OK\r\n"), | 445 MockRead(SYNCHRONOUS, 5, "HTTP/1.1 200 OK\r\n"), |
446 MockRead(false, 6, "Content-Length: 8\r\n\r\n"), | 446 MockRead(SYNCHRONOUS, 6, "Content-Length: 8\r\n\r\n"), |
447 MockRead(false, 7, "two.html"), | 447 MockRead(SYNCHRONOUS, 7, "two.html"), |
448 }; | 448 }; |
449 AddExpectedConnection(reads, arraysize(reads), writes, arraysize(writes)); | 449 AddExpectedConnection(reads, arraysize(reads), writes, arraysize(writes)); |
450 | 450 |
451 scoped_ptr<HttpNetworkTransaction> one_transaction( | 451 scoped_ptr<HttpNetworkTransaction> one_transaction( |
452 new HttpNetworkTransaction(session_.get())); | 452 new HttpNetworkTransaction(session_.get())); |
453 TestCompletionCallback one_callback; | 453 TestCompletionCallback one_callback; |
454 EXPECT_EQ(ERR_IO_PENDING, | 454 EXPECT_EQ(ERR_IO_PENDING, |
455 one_transaction->Start(GetRequestInfo("redirect.html"), | 455 one_transaction->Start(GetRequestInfo("redirect.html"), |
456 one_callback.callback(), BoundNetLog())); | 456 one_callback.callback(), BoundNetLog())); |
457 EXPECT_EQ(OK, one_callback.WaitForResult()); | 457 EXPECT_EQ(OK, one_callback.WaitForResult()); |
458 | 458 |
459 HttpNetworkTransaction two_transaction(session_.get()); | 459 HttpNetworkTransaction two_transaction(session_.get()); |
460 TestCompletionCallback two_callback; | 460 TestCompletionCallback two_callback; |
461 EXPECT_EQ(ERR_IO_PENDING, | 461 EXPECT_EQ(ERR_IO_PENDING, |
462 two_transaction.Start(GetRequestInfo("two.html"), | 462 two_transaction.Start(GetRequestInfo("two.html"), |
463 two_callback.callback(), BoundNetLog())); | 463 two_callback.callback(), BoundNetLog())); |
464 | 464 |
465 one_transaction.reset(); | 465 one_transaction.reset(); |
466 data_vector_[0]->RunFor(2); | 466 data_vector_[0]->RunFor(2); |
467 data_vector_[0]->SetStop(10); | 467 data_vector_[0]->SetStop(10); |
468 | 468 |
469 EXPECT_EQ(OK, two_callback.WaitForResult()); | 469 EXPECT_EQ(OK, two_callback.WaitForResult()); |
470 ExpectResponse("two.html", two_transaction); | 470 ExpectResponse("two.html", two_transaction); |
471 } | 471 } |
472 | 472 |
473 TEST_F(HttpPipelinedNetworkTransactionTest, BasicHttpAuthentication) { | 473 TEST_F(HttpPipelinedNetworkTransactionTest, BasicHttpAuthentication) { |
474 Initialize(); | 474 Initialize(); |
475 | 475 |
476 MockWrite writes[] = { | 476 MockWrite writes[] = { |
477 MockWrite(false, 0, "GET /one.html HTTP/1.1\r\n" | 477 MockWrite(SYNCHRONOUS, 0, "GET /one.html HTTP/1.1\r\n" |
478 "Host: localhost\r\n" | 478 "Host: localhost\r\n" |
479 "Connection: keep-alive\r\n\r\n"), | 479 "Connection: keep-alive\r\n\r\n"), |
480 MockWrite(false, 5, "GET /one.html HTTP/1.1\r\n" | 480 MockWrite(SYNCHRONOUS, 5, "GET /one.html HTTP/1.1\r\n" |
481 "Host: localhost\r\n" | 481 "Host: localhost\r\n" |
482 "Connection: keep-alive\r\n" | 482 "Connection: keep-alive\r\n" |
483 "Authorization: auth_token\r\n\r\n"), | 483 "Authorization: auth_token\r\n\r\n"), |
484 }; | 484 }; |
485 MockRead reads[] = { | 485 MockRead reads[] = { |
486 MockRead(false, 1, "HTTP/1.1 401 Authentication Required\r\n"), | 486 MockRead(SYNCHRONOUS, 1, "HTTP/1.1 401 Authentication Required\r\n"), |
487 MockRead(false, 2, "WWW-Authenticate: Basic realm=\"Secure Area\"\r\n"), | 487 MockRead(SYNCHRONOUS, 2, |
488 MockRead(false, 3, "Content-Length: 20\r\n\r\n"), | 488 "WWW-Authenticate: Basic realm=\"Secure Area\"\r\n"), |
489 MockRead(false, 4, "needs authentication"), | 489 MockRead(SYNCHRONOUS, 3, "Content-Length: 20\r\n\r\n"), |
490 MockRead(false, 6, "HTTP/1.1 200 OK\r\n"), | 490 MockRead(SYNCHRONOUS, 4, "needs authentication"), |
491 MockRead(false, 7, "Content-Length: 8\r\n\r\n"), | 491 MockRead(SYNCHRONOUS, 6, "HTTP/1.1 200 OK\r\n"), |
492 MockRead(false, 8, "one.html"), | 492 MockRead(SYNCHRONOUS, 7, "Content-Length: 8\r\n\r\n"), |
| 493 MockRead(SYNCHRONOUS, 8, "one.html"), |
493 }; | 494 }; |
494 AddExpectedConnection(reads, arraysize(reads), writes, arraysize(writes)); | 495 AddExpectedConnection(reads, arraysize(reads), writes, arraysize(writes)); |
495 | 496 |
496 HttpAuthHandlerMock* mock_auth = new HttpAuthHandlerMock; | 497 HttpAuthHandlerMock* mock_auth = new HttpAuthHandlerMock; |
497 std::string challenge_text = "Basic"; | 498 std::string challenge_text = "Basic"; |
498 HttpAuth::ChallengeTokenizer challenge(challenge_text.begin(), | 499 HttpAuth::ChallengeTokenizer challenge(challenge_text.begin(), |
499 challenge_text.end()); | 500 challenge_text.end()); |
500 GURL origin("localhost"); | 501 GURL origin("localhost"); |
501 EXPECT_TRUE(mock_auth->InitFromChallenge(&challenge, | 502 EXPECT_TRUE(mock_auth->InitFromChallenge(&challenge, |
502 HttpAuth::AUTH_SERVER, | 503 HttpAuth::AUTH_SERVER, |
(...skipping 10 matching lines...) Expand all Loading... |
513 AuthCredentials credentials(ASCIIToUTF16("user"), ASCIIToUTF16("pass")); | 514 AuthCredentials credentials(ASCIIToUTF16("user"), ASCIIToUTF16("pass")); |
514 EXPECT_EQ(OK, transaction.RestartWithAuth(credentials, callback_.callback())); | 515 EXPECT_EQ(OK, transaction.RestartWithAuth(credentials, callback_.callback())); |
515 | 516 |
516 ExpectResponse("one.html", transaction); | 517 ExpectResponse("one.html", transaction); |
517 } | 518 } |
518 | 519 |
519 TEST_F(HttpPipelinedNetworkTransactionTest, OldVersionDisablesPipelining) { | 520 TEST_F(HttpPipelinedNetworkTransactionTest, OldVersionDisablesPipelining) { |
520 Initialize(); | 521 Initialize(); |
521 | 522 |
522 MockWrite writes[] = { | 523 MockWrite writes[] = { |
523 MockWrite(false, 0, "GET /pipelined.html HTTP/1.1\r\n" | 524 MockWrite(SYNCHRONOUS, 0, "GET /pipelined.html HTTP/1.1\r\n" |
524 "Host: localhost\r\n" | 525 "Host: localhost\r\n" |
525 "Connection: keep-alive\r\n\r\n"), | 526 "Connection: keep-alive\r\n\r\n"), |
526 }; | 527 }; |
527 MockRead reads[] = { | 528 MockRead reads[] = { |
528 MockRead(false, 1, "HTTP/1.0 200 OK\r\n"), | 529 MockRead(SYNCHRONOUS, 1, "HTTP/1.0 200 OK\r\n"), |
529 MockRead(false, 2, "Content-Length: 14\r\n\r\n"), | 530 MockRead(SYNCHRONOUS, 2, "Content-Length: 14\r\n\r\n"), |
530 MockRead(false, 3, "pipelined.html"), | 531 MockRead(SYNCHRONOUS, 3, "pipelined.html"), |
531 }; | 532 }; |
532 AddExpectedConnection(reads, arraysize(reads), writes, arraysize(writes)); | 533 AddExpectedConnection(reads, arraysize(reads), writes, arraysize(writes)); |
533 | 534 |
534 MockWrite writes2[] = { | 535 MockWrite writes2[] = { |
535 MockWrite(false, 0, "GET /one.html HTTP/1.1\r\n" | 536 MockWrite(SYNCHRONOUS, 0, "GET /one.html HTTP/1.1\r\n" |
536 "Host: localhost\r\n" | 537 "Host: localhost\r\n" |
537 "Connection: keep-alive\r\n\r\n"), | 538 "Connection: keep-alive\r\n\r\n"), |
538 }; | 539 }; |
539 MockRead reads2[] = { | 540 MockRead reads2[] = { |
540 MockRead(false, 1, "HTTP/1.1 200 OK\r\n"), | 541 MockRead(SYNCHRONOUS, 1, "HTTP/1.1 200 OK\r\n"), |
541 MockRead(false, 2, "Content-Length: 8\r\n\r\n"), | 542 MockRead(SYNCHRONOUS, 2, "Content-Length: 8\r\n\r\n"), |
542 MockRead(true, 3, "one.html"), | 543 MockRead(ASYNC, 3, "one.html"), |
543 MockRead(false, OK, 4), | 544 MockRead(SYNCHRONOUS, OK, 4), |
544 }; | 545 }; |
545 AddExpectedConnection(reads2, arraysize(reads2), writes2, arraysize(writes2)); | 546 AddExpectedConnection(reads2, arraysize(reads2), writes2, arraysize(writes2)); |
546 | 547 |
547 MockWrite writes3[] = { | 548 MockWrite writes3[] = { |
548 MockWrite(false, 0, "GET /two.html HTTP/1.1\r\n" | 549 MockWrite(SYNCHRONOUS, 0, "GET /two.html HTTP/1.1\r\n" |
549 "Host: localhost\r\n" | 550 "Host: localhost\r\n" |
550 "Connection: keep-alive\r\n\r\n"), | 551 "Connection: keep-alive\r\n\r\n"), |
551 }; | 552 }; |
552 MockRead reads3[] = { | 553 MockRead reads3[] = { |
553 MockRead(false, 1, "HTTP/1.1 200 OK\r\n"), | 554 MockRead(SYNCHRONOUS, 1, "HTTP/1.1 200 OK\r\n"), |
554 MockRead(false, 2, "Content-Length: 8\r\n\r\n"), | 555 MockRead(SYNCHRONOUS, 2, "Content-Length: 8\r\n\r\n"), |
555 MockRead(false, 3, "two.html"), | 556 MockRead(SYNCHRONOUS, 3, "two.html"), |
556 MockRead(false, OK, 4), | 557 MockRead(SYNCHRONOUS, OK, 4), |
557 }; | 558 }; |
558 AddExpectedConnection(reads3, arraysize(reads3), writes3, arraysize(writes3)); | 559 AddExpectedConnection(reads3, arraysize(reads3), writes3, arraysize(writes3)); |
559 | 560 |
560 HttpNetworkTransaction one_transaction(session_.get()); | 561 HttpNetworkTransaction one_transaction(session_.get()); |
561 TestCompletionCallback one_callback; | 562 TestCompletionCallback one_callback; |
562 EXPECT_EQ(ERR_IO_PENDING, | 563 EXPECT_EQ(ERR_IO_PENDING, |
563 one_transaction.Start(GetRequestInfo("pipelined.html"), | 564 one_transaction.Start(GetRequestInfo("pipelined.html"), |
564 one_callback.callback(), BoundNetLog())); | 565 one_callback.callback(), BoundNetLog())); |
565 EXPECT_EQ(OK, one_callback.WaitForResult()); | 566 EXPECT_EQ(OK, one_callback.WaitForResult()); |
566 ExpectResponse("pipelined.html", one_transaction); | 567 ExpectResponse("pipelined.html", one_transaction); |
567 | 568 |
568 CompleteTwoRequests(1, 4); | 569 CompleteTwoRequests(1, 4); |
569 } | 570 } |
570 | 571 |
571 TEST_F(HttpPipelinedNetworkTransactionTest, PipelinesImmediatelyIfKnownGood) { | 572 TEST_F(HttpPipelinedNetworkTransactionTest, PipelinesImmediatelyIfKnownGood) { |
572 // The first request gets us an HTTP/1.1. The next 3 test pipelining. When the | 573 // The first request gets us an HTTP/1.1. The next 3 test pipelining. When the |
573 // 3rd request completes, we know pipelining is safe. After the first 4 | 574 // 3rd request completes, we know pipelining is safe. After the first 4 |
574 // complete, the 5th and 6th should then be immediately sent pipelined on a | 575 // complete, the 5th and 6th should then be immediately sent pipelined on a |
575 // new HttpPipelinedConnection. | 576 // new HttpPipelinedConnection. |
576 int old_max_sockets = ClientSocketPoolManager::max_sockets_per_group(); | 577 int old_max_sockets = ClientSocketPoolManager::max_sockets_per_group(); |
577 ClientSocketPoolManager::set_max_sockets_per_group(1); | 578 ClientSocketPoolManager::set_max_sockets_per_group(1); |
578 Initialize(); | 579 Initialize(); |
579 | 580 |
580 MockWrite writes[] = { | 581 MockWrite writes[] = { |
581 MockWrite(false, 0, "GET /one.html HTTP/1.1\r\n" | 582 MockWrite(SYNCHRONOUS, 0, "GET /one.html HTTP/1.1\r\n" |
582 "Host: localhost\r\n" | 583 "Host: localhost\r\n" |
583 "Connection: keep-alive\r\n\r\n"), | 584 "Connection: keep-alive\r\n\r\n"), |
584 MockWrite(false, 4, "GET /two.html HTTP/1.1\r\n" | 585 MockWrite(SYNCHRONOUS, 4, "GET /two.html HTTP/1.1\r\n" |
585 "Host: localhost\r\n" | 586 "Host: localhost\r\n" |
586 "Connection: keep-alive\r\n\r\n"), | 587 "Connection: keep-alive\r\n\r\n"), |
587 MockWrite(false, 7, "GET /three.html HTTP/1.1\r\n" | 588 MockWrite(SYNCHRONOUS, 7, "GET /three.html HTTP/1.1\r\n" |
588 "Host: localhost\r\n" | 589 "Host: localhost\r\n" |
589 "Connection: keep-alive\r\n\r\n"), | 590 "Connection: keep-alive\r\n\r\n"), |
590 MockWrite(false, 12, "GET /four.html HTTP/1.1\r\n" | 591 MockWrite(SYNCHRONOUS, 12, "GET /four.html HTTP/1.1\r\n" |
591 "Host: localhost\r\n" | 592 "Host: localhost\r\n" |
592 "Connection: keep-alive\r\n\r\n"), | 593 "Connection: keep-alive\r\n\r\n"), |
593 MockWrite(false, 16, "GET /second-pipeline-one.html HTTP/1.1\r\n" | 594 MockWrite(SYNCHRONOUS, 16, "GET /second-pipeline-one.html HTTP/1.1\r\n" |
594 "Host: localhost\r\n" | 595 "Host: localhost\r\n" |
595 "Connection: keep-alive\r\n\r\n"), | 596 "Connection: keep-alive\r\n\r\n"), |
596 MockWrite(false, 17, "GET /second-pipeline-two.html HTTP/1.1\r\n" | 597 MockWrite(SYNCHRONOUS, 17, "GET /second-pipeline-two.html HTTP/1.1\r\n" |
597 "Host: localhost\r\n" | 598 "Host: localhost\r\n" |
598 "Connection: keep-alive\r\n\r\n"), | 599 "Connection: keep-alive\r\n\r\n"), |
599 }; | 600 }; |
600 MockRead reads[] = { | 601 MockRead reads[] = { |
601 MockRead(false, 1, "HTTP/1.1 200 OK\r\n"), | 602 MockRead(SYNCHRONOUS, 1, "HTTP/1.1 200 OK\r\n"), |
602 MockRead(false, 2, "Content-Length: 8\r\n\r\n"), | 603 MockRead(SYNCHRONOUS, 2, "Content-Length: 8\r\n\r\n"), |
603 MockRead(false, 3, "one.html"), | 604 MockRead(SYNCHRONOUS, 3, "one.html"), |
604 MockRead(false, 5, "HTTP/1.1 200 OK\r\n"), | 605 MockRead(SYNCHRONOUS, 5, "HTTP/1.1 200 OK\r\n"), |
605 MockRead(false, 6, "Content-Length: 8\r\n\r\n"), | 606 MockRead(SYNCHRONOUS, 6, "Content-Length: 8\r\n\r\n"), |
606 MockRead(false, 8, "two.html"), | 607 MockRead(SYNCHRONOUS, 8, "two.html"), |
607 MockRead(false, 9, "HTTP/1.1 200 OK\r\n"), | 608 MockRead(SYNCHRONOUS, 9, "HTTP/1.1 200 OK\r\n"), |
608 MockRead(false, 10, "Content-Length: 10\r\n\r\n"), | 609 MockRead(SYNCHRONOUS, 10, "Content-Length: 10\r\n\r\n"), |
609 MockRead(false, 11, "three.html"), | 610 MockRead(SYNCHRONOUS, 11, "three.html"), |
610 MockRead(false, 13, "HTTP/1.1 200 OK\r\n"), | 611 MockRead(SYNCHRONOUS, 13, "HTTP/1.1 200 OK\r\n"), |
611 MockRead(false, 14, "Content-Length: 9\r\n\r\n"), | 612 MockRead(SYNCHRONOUS, 14, "Content-Length: 9\r\n\r\n"), |
612 MockRead(false, 15, "four.html"), | 613 MockRead(SYNCHRONOUS, 15, "four.html"), |
613 MockRead(true, 18, "HTTP/1.1 200 OK\r\n"), | 614 MockRead(ASYNC, 18, "HTTP/1.1 200 OK\r\n"), |
614 MockRead(true, 19, "Content-Length: 24\r\n\r\n"), | 615 MockRead(ASYNC, 19, "Content-Length: 24\r\n\r\n"), |
615 MockRead(false, 20, "second-pipeline-one.html"), | 616 MockRead(SYNCHRONOUS, 20, "second-pipeline-one.html"), |
616 MockRead(false, 21, "HTTP/1.1 200 OK\r\n"), | 617 MockRead(SYNCHRONOUS, 21, "HTTP/1.1 200 OK\r\n"), |
617 MockRead(false, 22, "Content-Length: 24\r\n\r\n"), | 618 MockRead(SYNCHRONOUS, 22, "Content-Length: 24\r\n\r\n"), |
618 MockRead(false, 23, "second-pipeline-two.html"), | 619 MockRead(SYNCHRONOUS, 23, "second-pipeline-two.html"), |
619 }; | 620 }; |
620 AddExpectedConnection(reads, arraysize(reads), writes, arraysize(writes)); | 621 AddExpectedConnection(reads, arraysize(reads), writes, arraysize(writes)); |
621 | 622 |
622 CompleteFourRequests(); | 623 CompleteFourRequests(); |
623 | 624 |
624 HttpNetworkTransaction second_one_transaction(session_.get()); | 625 HttpNetworkTransaction second_one_transaction(session_.get()); |
625 TestCompletionCallback second_one_callback; | 626 TestCompletionCallback second_one_callback; |
626 EXPECT_EQ(ERR_IO_PENDING, | 627 EXPECT_EQ(ERR_IO_PENDING, |
627 second_one_transaction.Start( | 628 second_one_transaction.Start( |
628 GetRequestInfo("second-pipeline-one.html"), | 629 GetRequestInfo("second-pipeline-one.html"), |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
679 // determines this host is probably capable of pipelining. | 680 // determines this host is probably capable of pipelining. |
680 // 4. All of the hosts' pipelines are notified they have capacity in a loop. | 681 // 4. All of the hosts' pipelines are notified they have capacity in a loop. |
681 // 5. On the first iteration, the first pipeline is opened up to accept new | 682 // 5. On the first iteration, the first pipeline is opened up to accept new |
682 // requests and steals the request from step #2. | 683 // requests and steals the request from step #2. |
683 // 6. The pipeline from #2 is deleted because it has no streams. | 684 // 6. The pipeline from #2 is deleted because it has no streams. |
684 // 7. On the second iteration, the host tries to notify the pipeline from step | 685 // 7. On the second iteration, the host tries to notify the pipeline from step |
685 // #2 that it has capacity. This is a use-after-free. | 686 // #2 that it has capacity. This is a use-after-free. |
686 Initialize(); | 687 Initialize(); |
687 | 688 |
688 MockWrite writes[] = { | 689 MockWrite writes[] = { |
689 MockWrite(false, 0, "GET /one.html HTTP/1.1\r\n" | 690 MockWrite(SYNCHRONOUS, 0, "GET /one.html HTTP/1.1\r\n" |
690 "Host: localhost\r\n" | 691 "Host: localhost\r\n" |
691 "Connection: keep-alive\r\n\r\n"), | 692 "Connection: keep-alive\r\n\r\n"), |
692 MockWrite(true, 3, "GET /two.html HTTP/1.1\r\n" | 693 MockWrite(ASYNC, 3, "GET /two.html HTTP/1.1\r\n" |
693 "Host: localhost\r\n" | 694 "Host: localhost\r\n" |
694 "Connection: keep-alive\r\n\r\n"), | 695 "Connection: keep-alive\r\n\r\n"), |
695 }; | 696 }; |
696 MockRead reads[] = { | 697 MockRead reads[] = { |
697 MockRead(false, 1, "HTTP/1.1 200 OK\r\n"), | 698 MockRead(SYNCHRONOUS, 1, "HTTP/1.1 200 OK\r\n"), |
698 MockRead(true, 2, "Content-Length: 8\r\n\r\n"), | 699 MockRead(ASYNC, 2, "Content-Length: 8\r\n\r\n"), |
699 MockRead(false, 4, "one.html"), | 700 MockRead(SYNCHRONOUS, 4, "one.html"), |
700 MockRead(false, 5, "HTTP/1.1 200 OK\r\n"), | 701 MockRead(SYNCHRONOUS, 5, "HTTP/1.1 200 OK\r\n"), |
701 MockRead(false, 6, "Content-Length: 8\r\n\r\n"), | 702 MockRead(SYNCHRONOUS, 6, "Content-Length: 8\r\n\r\n"), |
702 MockRead(false, 7, "two.html"), | 703 MockRead(SYNCHRONOUS, 7, "two.html"), |
703 }; | 704 }; |
704 AddExpectedConnection(reads, arraysize(reads), writes, arraysize(writes)); | 705 AddExpectedConnection(reads, arraysize(reads), writes, arraysize(writes)); |
705 | 706 |
706 AddExpectedConnection(NULL, 0, NULL, 0); | 707 AddExpectedConnection(NULL, 0, NULL, 0); |
707 | 708 |
708 HttpNetworkTransaction one_transaction(session_.get()); | 709 HttpNetworkTransaction one_transaction(session_.get()); |
709 TestCompletionCallback one_callback; | 710 TestCompletionCallback one_callback; |
710 EXPECT_EQ(ERR_IO_PENDING, | 711 EXPECT_EQ(ERR_IO_PENDING, |
711 one_transaction.Start(GetRequestInfo("one.html"), | 712 one_transaction.Start(GetRequestInfo("one.html"), |
712 one_callback.callback(), BoundNetLog())); | 713 one_callback.callback(), BoundNetLog())); |
(...skipping 22 matching lines...) Expand all Loading... |
735 | 736 |
736 EXPECT_EQ(OK, one_callback.WaitForResult()); | 737 EXPECT_EQ(OK, one_callback.WaitForResult()); |
737 ExpectResponse("one.html", one_transaction); | 738 ExpectResponse("one.html", one_transaction); |
738 EXPECT_EQ(OK, two_callback.WaitForResult()); | 739 EXPECT_EQ(OK, two_callback.WaitForResult()); |
739 ExpectResponse("two.html", two_transaction); | 740 ExpectResponse("two.html", two_transaction); |
740 } | 741 } |
741 | 742 |
742 } // anonymous namespace | 743 } // anonymous namespace |
743 | 744 |
744 } // namespace net | 745 } // namespace net |
OLD | NEW |