| 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 1637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1648 HttpRequestInfo request; | 1648 HttpRequestInfo request; |
| 1649 request.method = "POST"; | 1649 request.method = "POST"; |
| 1650 request.url = GURL("http://www.google.com/"); | 1650 request.url = GURL("http://www.google.com/"); |
| 1651 // Create an empty UploadData. | 1651 // Create an empty UploadData. |
| 1652 request.upload_data = new UploadData(); | 1652 request.upload_data = new UploadData(); |
| 1653 | 1653 |
| 1654 // Http POST Content-Length is using UploadDataStream::size(). | 1654 // Http POST Content-Length is using UploadDataStream::size(). |
| 1655 // It is the same as request.upload_data->GetContentLengthSync(). | 1655 // It is the same as request.upload_data->GetContentLengthSync(). |
| 1656 scoped_ptr<UploadDataStream> stream( | 1656 scoped_ptr<UploadDataStream> stream( |
| 1657 new UploadDataStream(request.upload_data)); | 1657 new UploadDataStream(request.upload_data)); |
| 1658 ASSERT_EQ(OK, stream->Init()); | 1658 ASSERT_EQ(OK, stream->InitSync()); |
| 1659 ASSERT_EQ(request.upload_data->GetContentLengthSync(), | 1659 ASSERT_EQ(request.upload_data->GetContentLengthSync(), |
| 1660 stream->size()); | 1660 stream->size()); |
| 1661 | 1661 |
| 1662 scoped_ptr<SpdyFrame> | 1662 scoped_ptr<SpdyFrame> |
| 1663 req(ConstructSpdyPost( | 1663 req(ConstructSpdyPost( |
| 1664 request.upload_data->GetContentLengthSync(), NULL, 0)); | 1664 request.upload_data->GetContentLengthSync(), NULL, 0)); |
| 1665 // Set the FIN bit since there will be no body. | 1665 // Set the FIN bit since there will be no body. |
| 1666 req->set_flags(CONTROL_FLAG_FIN); | 1666 req->set_flags(CONTROL_FLAG_FIN); |
| 1667 MockWrite writes[] = { | 1667 MockWrite writes[] = { |
| 1668 CreateMockWrite(*req), | 1668 CreateMockWrite(*req), |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1696 HttpRequestInfo request; | 1696 HttpRequestInfo request; |
| 1697 request.method = "POST"; | 1697 request.method = "POST"; |
| 1698 request.url = GURL("http://www.google.com/"); | 1698 request.url = GURL("http://www.google.com/"); |
| 1699 request.upload_data = new UploadData(); | 1699 request.upload_data = new UploadData(); |
| 1700 request.upload_data->AppendBytes(upload, sizeof(upload)); | 1700 request.upload_data->AppendBytes(upload, sizeof(upload)); |
| 1701 | 1701 |
| 1702 // Http POST Content-Length is using UploadDataStream::size(). | 1702 // Http POST Content-Length is using UploadDataStream::size(). |
| 1703 // It is the same as request.upload_data->GetContentLengthSync(). | 1703 // It is the same as request.upload_data->GetContentLengthSync(). |
| 1704 scoped_ptr<UploadDataStream> stream( | 1704 scoped_ptr<UploadDataStream> stream( |
| 1705 new UploadDataStream(request.upload_data)); | 1705 new UploadDataStream(request.upload_data)); |
| 1706 ASSERT_EQ(OK, stream->Init()); | 1706 ASSERT_EQ(OK, stream->InitSync()); |
| 1707 ASSERT_EQ(request.upload_data->GetContentLengthSync(), | 1707 ASSERT_EQ(request.upload_data->GetContentLengthSync(), |
| 1708 stream->size()); | 1708 stream->size()); |
| 1709 scoped_ptr<SpdyFrame> stream_reply(ConstructSpdyPostSynReply(NULL, 0)); | 1709 scoped_ptr<SpdyFrame> stream_reply(ConstructSpdyPostSynReply(NULL, 0)); |
| 1710 scoped_ptr<SpdyFrame> stream_body(ConstructSpdyBodyFrame(1, true)); | 1710 scoped_ptr<SpdyFrame> stream_body(ConstructSpdyBodyFrame(1, true)); |
| 1711 MockRead reads[] = { | 1711 MockRead reads[] = { |
| 1712 CreateMockRead(*stream_reply, 1), | 1712 CreateMockRead(*stream_reply, 1), |
| 1713 MockRead(ASYNC, 0, 3) // EOF | 1713 MockRead(ASYNC, 0, 3) // EOF |
| 1714 }; | 1714 }; |
| 1715 | 1715 |
| 1716 scoped_ptr<SpdyFrame> req(ConstructSpdyPost(kUploadDataSize, NULL, 0)); | 1716 scoped_ptr<SpdyFrame> req(ConstructSpdyPost(kUploadDataSize, NULL, 0)); |
| (...skipping 3953 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5670 // And now we can allow everything else to run to completion. | 5670 // And now we can allow everything else to run to completion. |
| 5671 data.SetStop(10); | 5671 data.SetStop(10); |
| 5672 data.Run(); | 5672 data.Run(); |
| 5673 EXPECT_EQ(OK, callback2.WaitForResult()); | 5673 EXPECT_EQ(OK, callback2.WaitForResult()); |
| 5674 EXPECT_EQ(OK, callback3.WaitForResult()); | 5674 EXPECT_EQ(OK, callback3.WaitForResult()); |
| 5675 | 5675 |
| 5676 helper.VerifyDataConsumed(); | 5676 helper.VerifyDataConsumed(); |
| 5677 } | 5677 } |
| 5678 | 5678 |
| 5679 } // namespace net | 5679 } // namespace net |
| OLD | NEW |