OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <windows.h> | 5 #include <windows.h> |
6 #include <objbase.h> | 6 #include <objbase.h> |
7 #include <urlmon.h> | 7 #include <urlmon.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/string_number_conversions.h" | 11 #include "base/string_number_conversions.h" |
| 12 #include "base/string_piece.h" |
12 #include "base/string_util.h" | 13 #include "base/string_util.h" |
13 #include "base/stringprintf.h" | 14 #include "base/stringprintf.h" |
14 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
15 #include "chrome_frame/test/test_server.h" | 16 #include "chrome_frame/test/test_server.h" |
16 #include "net/base/winsock_init.h" | 17 #include "net/base/winsock_init.h" |
17 #include "net/http/http_util.h" | 18 #include "net/http/http_util.h" |
18 | 19 |
19 namespace test_server { | 20 namespace test_server { |
20 const char kDefaultHeaderTemplate[] = | 21 const char kDefaultHeaderTemplate[] = |
21 "HTTP/1.1 %hs\r\n" | 22 "HTTP/1.1 %hs\r\n" |
(...skipping 20 matching lines...) Expand all Loading... |
42 tokenizer.token_end()); | 43 tokenizer.token_end()); |
43 } | 44 } |
44 } | 45 } |
45 | 46 |
46 // Check for content-length in case we're being sent some data. | 47 // Check for content-length in case we're being sent some data. |
47 net::HttpUtil::HeadersIterator it(headers_.begin(), headers_.end(), | 48 net::HttpUtil::HeadersIterator it(headers_.begin(), headers_.end(), |
48 "\r\n"); | 49 "\r\n"); |
49 while (it.GetNext()) { | 50 while (it.GetNext()) { |
50 if (LowerCaseEqualsASCII(it.name(), "content-length")) { | 51 if (LowerCaseEqualsASCII(it.name(), "content-length")) { |
51 int int_content_length; | 52 int int_content_length; |
52 base::StringToInt(it.values_begin(), | 53 base::StringToInt(base::StringPiece(it.values_begin(), |
53 it.values_end(), | 54 it.values_end()), |
54 &int_content_length); | 55 &int_content_length); |
55 content_length_ = int_content_length; | 56 content_length_ = int_content_length; |
56 break; | 57 break; |
57 } | 58 } |
58 } | 59 } |
59 } | 60 } |
60 | 61 |
61 void Request::OnDataReceived(const std::string& data) { | 62 void Request::OnDataReceived(const std::string& data) { |
62 content_ += data; | 63 content_ += data; |
63 | 64 |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 data_.append(content_length_header); | 373 data_.append(content_length_header); |
373 data_.append("\r\n"); | 374 data_.append("\r\n"); |
374 } | 375 } |
375 | 376 |
376 MessageLoop::current()->PostDelayedTask( | 377 MessageLoop::current()->PostDelayedTask( |
377 FROM_HERE, base::Bind(&ConfigurableConnection::SendChunk, this), | 378 FROM_HERE, base::Bind(&ConfigurableConnection::SendChunk, this), |
378 options.timeout_); | 379 options.timeout_); |
379 } | 380 } |
380 | 381 |
381 } // namespace test_server | 382 } // namespace test_server |
OLD | NEW |