| 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/http/http_network_transaction.h" | 5 #include "net/http/http_network_transaction.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 1643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1654 HttpRequestInfo request; | 1654 HttpRequestInfo request; |
| 1655 request.method = "POST"; | 1655 request.method = "POST"; |
| 1656 request.url = GURL("http://www.google.com/"); | 1656 request.url = GURL("http://www.google.com/"); |
| 1657 // Create an empty UploadData. | 1657 // Create an empty UploadData. |
| 1658 request.upload_data = new UploadData(); | 1658 request.upload_data = new UploadData(); |
| 1659 | 1659 |
| 1660 // Http POST Content-Length is using UploadDataStream::size(). | 1660 // Http POST Content-Length is using UploadDataStream::size(). |
| 1661 const uint64 kContentLength = 0; | 1661 const uint64 kContentLength = 0; |
| 1662 scoped_ptr<UploadDataStream> stream( | 1662 scoped_ptr<UploadDataStream> stream( |
| 1663 new UploadDataStream(request.upload_data)); | 1663 new UploadDataStream(request.upload_data)); |
| 1664 ASSERT_EQ(OK, stream->Init()); | 1664 ASSERT_EQ(OK, stream->InitSync()); |
| 1665 ASSERT_EQ(kContentLength, stream->size()); | 1665 ASSERT_EQ(kContentLength, stream->size()); |
| 1666 | 1666 |
| 1667 scoped_ptr<SpdyFrame> req(ConstructSpdyPost(kContentLength, NULL, 0)); | 1667 scoped_ptr<SpdyFrame> req(ConstructSpdyPost(kContentLength, NULL, 0)); |
| 1668 // Set the FIN bit since there will be no body. | 1668 // Set the FIN bit since there will be no body. |
| 1669 req->set_flags(CONTROL_FLAG_FIN); | 1669 req->set_flags(CONTROL_FLAG_FIN); |
| 1670 MockWrite writes[] = { | 1670 MockWrite writes[] = { |
| 1671 CreateMockWrite(*req), | 1671 CreateMockWrite(*req), |
| 1672 }; | 1672 }; |
| 1673 | 1673 |
| 1674 scoped_ptr<SpdyFrame> resp(ConstructSpdyPostSynReply(NULL, 0)); | 1674 scoped_ptr<SpdyFrame> resp(ConstructSpdyPostSynReply(NULL, 0)); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1699 HttpRequestInfo request; | 1699 HttpRequestInfo request; |
| 1700 request.method = "POST"; | 1700 request.method = "POST"; |
| 1701 request.url = GURL("http://www.google.com/"); | 1701 request.url = GURL("http://www.google.com/"); |
| 1702 request.upload_data = new UploadData(); | 1702 request.upload_data = new UploadData(); |
| 1703 request.upload_data->AppendBytes(upload, sizeof(upload)); | 1703 request.upload_data->AppendBytes(upload, sizeof(upload)); |
| 1704 | 1704 |
| 1705 // Http POST Content-Length is using UploadDataStream::size(). | 1705 // Http POST Content-Length is using UploadDataStream::size(). |
| 1706 const uint64 kContentLength = sizeof(upload); | 1706 const uint64 kContentLength = sizeof(upload); |
| 1707 scoped_ptr<UploadDataStream> stream( | 1707 scoped_ptr<UploadDataStream> stream( |
| 1708 new UploadDataStream(request.upload_data)); | 1708 new UploadDataStream(request.upload_data)); |
| 1709 ASSERT_EQ(OK, stream->Init()); | 1709 ASSERT_EQ(OK, stream->InitSync()); |
| 1710 ASSERT_EQ(kContentLength, stream->size()); | 1710 ASSERT_EQ(kContentLength, stream->size()); |
| 1711 scoped_ptr<SpdyFrame> stream_reply(ConstructSpdyPostSynReply(NULL, 0)); | 1711 scoped_ptr<SpdyFrame> stream_reply(ConstructSpdyPostSynReply(NULL, 0)); |
| 1712 scoped_ptr<SpdyFrame> stream_body(ConstructSpdyBodyFrame(1, true)); | 1712 scoped_ptr<SpdyFrame> stream_body(ConstructSpdyBodyFrame(1, true)); |
| 1713 MockRead reads[] = { | 1713 MockRead reads[] = { |
| 1714 CreateMockRead(*stream_reply, 1), | 1714 CreateMockRead(*stream_reply, 1), |
| 1715 MockRead(ASYNC, 0, 3) // EOF | 1715 MockRead(ASYNC, 0, 3) // EOF |
| 1716 }; | 1716 }; |
| 1717 | 1717 |
| 1718 scoped_ptr<SpdyFrame> req(ConstructSpdyPost(kUploadDataSize, NULL, 0)); | 1718 scoped_ptr<SpdyFrame> req(ConstructSpdyPost(kUploadDataSize, NULL, 0)); |
| 1719 scoped_ptr<SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); | 1719 scoped_ptr<SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); |
| (...skipping 4506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6226 // And now we can allow everything else to run to completion. | 6226 // And now we can allow everything else to run to completion. |
| 6227 data.SetStop(10); | 6227 data.SetStop(10); |
| 6228 data.Run(); | 6228 data.Run(); |
| 6229 EXPECT_EQ(OK, callback2.WaitForResult()); | 6229 EXPECT_EQ(OK, callback2.WaitForResult()); |
| 6230 EXPECT_EQ(OK, callback3.WaitForResult()); | 6230 EXPECT_EQ(OK, callback3.WaitForResult()); |
| 6231 | 6231 |
| 6232 helper.VerifyDataConsumed(); | 6232 helper.VerifyDataConsumed(); |
| 6233 } | 6233 } |
| 6234 | 6234 |
| 6235 } // namespace net | 6235 } // namespace net |
| OLD | NEW |