| 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 // It is the same as request.upload_data->GetContentLengthSync(). | 1661 // It is the same as request.upload_data->GetContentLengthSync(). |
| 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(request.upload_data->GetContentLengthSync(), | 1665 ASSERT_EQ(request.upload_data->GetContentLengthSync(), |
| 1666 stream->size()); | 1666 stream->size()); |
| 1667 | 1667 |
| 1668 scoped_ptr<SpdyFrame> | 1668 scoped_ptr<SpdyFrame> |
| 1669 req(ConstructSpdyPost( | 1669 req(ConstructSpdyPost( |
| 1670 request.upload_data->GetContentLengthSync(), NULL, 0)); | 1670 request.upload_data->GetContentLengthSync(), NULL, 0)); |
| 1671 // Set the FIN bit since there will be no body. | 1671 // Set the FIN bit since there will be no body. |
| 1672 req->set_flags(CONTROL_FLAG_FIN); | 1672 req->set_flags(CONTROL_FLAG_FIN); |
| 1673 MockWrite writes[] = { | 1673 MockWrite writes[] = { |
| 1674 CreateMockWrite(*req), | 1674 CreateMockWrite(*req), |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1702 HttpRequestInfo request; | 1702 HttpRequestInfo request; |
| 1703 request.method = "POST"; | 1703 request.method = "POST"; |
| 1704 request.url = GURL("http://www.google.com/"); | 1704 request.url = GURL("http://www.google.com/"); |
| 1705 request.upload_data = new UploadData(); | 1705 request.upload_data = new UploadData(); |
| 1706 request.upload_data->AppendBytes(upload, sizeof(upload)); | 1706 request.upload_data->AppendBytes(upload, sizeof(upload)); |
| 1707 | 1707 |
| 1708 // Http POST Content-Length is using UploadDataStream::size(). | 1708 // Http POST Content-Length is using UploadDataStream::size(). |
| 1709 // It is the same as request.upload_data->GetContentLengthSync(). | 1709 // It is the same as request.upload_data->GetContentLengthSync(). |
| 1710 scoped_ptr<UploadDataStream> stream( | 1710 scoped_ptr<UploadDataStream> stream( |
| 1711 new UploadDataStream(request.upload_data)); | 1711 new UploadDataStream(request.upload_data)); |
| 1712 ASSERT_EQ(OK, stream->Init()); | 1712 ASSERT_EQ(OK, stream->InitSync()); |
| 1713 ASSERT_EQ(request.upload_data->GetContentLengthSync(), | 1713 ASSERT_EQ(request.upload_data->GetContentLengthSync(), |
| 1714 stream->size()); | 1714 stream->size()); |
| 1715 scoped_ptr<SpdyFrame> stream_reply(ConstructSpdyPostSynReply(NULL, 0)); | 1715 scoped_ptr<SpdyFrame> stream_reply(ConstructSpdyPostSynReply(NULL, 0)); |
| 1716 scoped_ptr<SpdyFrame> stream_body(ConstructSpdyBodyFrame(1, true)); | 1716 scoped_ptr<SpdyFrame> stream_body(ConstructSpdyBodyFrame(1, true)); |
| 1717 MockRead reads[] = { | 1717 MockRead reads[] = { |
| 1718 CreateMockRead(*stream_reply, 1), | 1718 CreateMockRead(*stream_reply, 1), |
| 1719 MockRead(ASYNC, 0, 3) // EOF | 1719 MockRead(ASYNC, 0, 3) // EOF |
| 1720 }; | 1720 }; |
| 1721 | 1721 |
| 1722 scoped_ptr<SpdyFrame> req(ConstructSpdyPost(kUploadDataSize, NULL, 0)); | 1722 scoped_ptr<SpdyFrame> req(ConstructSpdyPost(kUploadDataSize, NULL, 0)); |
| (...skipping 4507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6230 // And now we can allow everything else to run to completion. | 6230 // And now we can allow everything else to run to completion. |
| 6231 data.SetStop(10); | 6231 data.SetStop(10); |
| 6232 data.Run(); | 6232 data.Run(); |
| 6233 EXPECT_EQ(OK, callback2.WaitForResult()); | 6233 EXPECT_EQ(OK, callback2.WaitForResult()); |
| 6234 EXPECT_EQ(OK, callback3.WaitForResult()); | 6234 EXPECT_EQ(OK, callback3.WaitForResult()); |
| 6235 | 6235 |
| 6236 helper.VerifyDataConsumed(); | 6236 helper.VerifyDataConsumed(); |
| 6237 } | 6237 } |
| 6238 | 6238 |
| 6239 } // namespace net | 6239 } // namespace net |
| OLD | NEW |