Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(366)

Side by Side Diff: net/http/http_stream_parser_unittest.cc

Issue 1841863002: Update monet. (Closed) Base URL: https://github.com/domokit/monet.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/http/http_stream_factory.cc ('k') | net/http/http_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/files/file_util.h" 12 #include "base/files/file_util.h"
13 #include "base/files/scoped_temp_dir.h" 13 #include "base/files/scoped_temp_dir.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/run_loop.h" 15 #include "base/run_loop.h"
16 #include "base/strings/string_piece.h" 16 #include "base/strings/string_piece.h"
17 #include "base/strings/stringprintf.h" 17 #include "base/strings/stringprintf.h"
18 #include "base/thread_task_runner_handle.h"
18 #include "net/base/chunked_upload_data_stream.h" 19 #include "net/base/chunked_upload_data_stream.h"
19 #include "net/base/elements_upload_data_stream.h" 20 #include "net/base/elements_upload_data_stream.h"
20 #include "net/base/io_buffer.h" 21 #include "net/base/io_buffer.h"
21 #include "net/base/net_errors.h" 22 #include "net/base/net_errors.h"
22 #include "net/base/test_completion_callback.h" 23 #include "net/base/test_completion_callback.h"
23 #include "net/base/upload_bytes_element_reader.h" 24 #include "net/base/upload_bytes_element_reader.h"
24 #include "net/base/upload_file_element_reader.h" 25 #include "net/base/upload_file_element_reader.h"
25 #include "net/http/http_request_headers.h" 26 #include "net/http/http_request_headers.h"
26 #include "net/http/http_request_info.h" 27 #include "net/http/http_request_info.h"
27 #include "net/http/http_response_headers.h" 28 #include "net/http/http_response_headers.h"
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 ScopedVector<UploadElementReader> element_readers; 148 ScopedVector<UploadElementReader> element_readers;
148 149
149 // Create an empty temporary file. 150 // Create an empty temporary file.
150 base::ScopedTempDir temp_dir; 151 base::ScopedTempDir temp_dir;
151 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); 152 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
152 base::FilePath temp_file_path; 153 base::FilePath temp_file_path;
153 ASSERT_TRUE(base::CreateTemporaryFileInDir(temp_dir.path(), 154 ASSERT_TRUE(base::CreateTemporaryFileInDir(temp_dir.path(),
154 &temp_file_path)); 155 &temp_file_path));
155 156
156 element_readers.push_back( 157 element_readers.push_back(
157 new UploadFileElementReader(base::MessageLoopProxy::current().get(), 158 new UploadFileElementReader(base::ThreadTaskRunnerHandle::Get().get(),
158 temp_file_path, 159 temp_file_path, 0, 0, base::Time()));
159 0,
160 0,
161 base::Time()));
162 160
163 scoped_ptr<UploadDataStream> body( 161 scoped_ptr<UploadDataStream> body(
164 new ElementsUploadDataStream(element_readers.Pass(), 0)); 162 new ElementsUploadDataStream(element_readers.Pass(), 0));
165 TestCompletionCallback callback; 163 TestCompletionCallback callback;
166 ASSERT_EQ(ERR_IO_PENDING, body->Init(callback.callback())); 164 ASSERT_EQ(ERR_IO_PENDING, body->Init(callback.callback()));
167 ASSERT_EQ(OK, callback.WaitForResult()); 165 ASSERT_EQ(OK, callback.WaitForResult());
168 // Shouldn't be merged if upload data carries a file, as it's not in-memory. 166 // Shouldn't be merged if upload data carries a file, as it's not in-memory.
169 ASSERT_FALSE(HttpStreamParser::ShouldMergeRequestHeadersAndBody( 167 ASSERT_FALSE(HttpStreamParser::ShouldMergeRequestHeadersAndBody(
170 "some header", body.get())); 168 "some header", body.get()));
171 } 169 }
(...skipping 992 matching lines...) Expand 10 before | Expand all | Expand 10 after
1164 response_info.reset(); 1162 response_info.reset();
1165 1163
1166 scoped_refptr<IOBuffer> body_buffer(new IOBuffer(kBodySize)); 1164 scoped_refptr<IOBuffer> body_buffer(new IOBuffer(kBodySize));
1167 ASSERT_EQ(kBodySize, parser.ReadResponseBody( 1165 ASSERT_EQ(kBodySize, parser.ReadResponseBody(
1168 body_buffer.get(), kBodySize, callback.callback())); 1166 body_buffer.get(), kBodySize, callback.callback()));
1169 } 1167 }
1170 1168
1171 } // namespace 1169 } // namespace
1172 1170
1173 } // namespace net 1171 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_stream_factory.cc ('k') | net/http/http_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698