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_stream_parser.h" | 5 #include "net/http/http_stream_parser.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 TestCompletionCallback callback; | 548 TestCompletionCallback callback; |
549 EXPECT_EQ(OK, parser_->ReadResponseHeaders(callback.callback())); | 549 EXPECT_EQ(OK, parser_->ReadResponseHeaders(callback.callback())); |
550 } | 550 } |
551 | 551 |
552 void ReadBody(int user_buf_len, int* read_lengths) { | 552 void ReadBody(int user_buf_len, int* read_lengths) { |
553 TestCompletionCallback callback; | 553 TestCompletionCallback callback; |
554 scoped_refptr<IOBuffer> buffer = new IOBuffer(user_buf_len); | 554 scoped_refptr<IOBuffer> buffer = new IOBuffer(user_buf_len); |
555 int rv; | 555 int rv; |
556 int i = 0; | 556 int i = 0; |
557 while (true) { | 557 while (true) { |
558 rv = parser_->ReadResponseBody(buffer, user_buf_len, callback.callback()); | 558 rv = parser_->ReadResponseBody( |
| 559 buffer.get(), user_buf_len, callback.callback()); |
559 EXPECT_EQ(read_lengths[i], rv); | 560 EXPECT_EQ(read_lengths[i], rv); |
560 i++; | 561 i++; |
561 if (rv <= 0) | 562 if (rv <= 0) |
562 return; | 563 return; |
563 } | 564 } |
564 } | 565 } |
565 | 566 |
566 private: | 567 private: |
567 HttpRequestHeaders request_headers_; | 568 HttpRequestHeaders request_headers_; |
568 HttpResponseInfo response_info_; | 569 HttpResponseInfo response_info_; |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
857 response_info.reset(); | 858 response_info.reset(); |
858 | 859 |
859 scoped_refptr<IOBuffer> body_buffer(new IOBuffer(kBodySize)); | 860 scoped_refptr<IOBuffer> body_buffer(new IOBuffer(kBodySize)); |
860 ASSERT_EQ(kBodySize, parser.ReadResponseBody( | 861 ASSERT_EQ(kBodySize, parser.ReadResponseBody( |
861 body_buffer.get(), kBodySize, callback.callback())); | 862 body_buffer.get(), kBodySize, callback.callback())); |
862 } | 863 } |
863 | 864 |
864 } // namespace | 865 } // namespace |
865 | 866 |
866 } // namespace net | 867 } // namespace net |
OLD | NEW |