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 <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" |
(...skipping 19 matching lines...) Expand all Loading... |
30 const char kDefaultContentType[] = "text/html; charset=UTF-8"; | 30 const char kDefaultContentType[] = "text/html; charset=UTF-8"; |
31 | 31 |
32 void Request::ParseHeaders(const std::string& headers) { | 32 void Request::ParseHeaders(const std::string& headers) { |
33 DCHECK(method_.length() == 0); | 33 DCHECK(method_.length() == 0); |
34 | 34 |
35 size_t pos = headers.find("\r\n"); | 35 size_t pos = headers.find("\r\n"); |
36 DCHECK(pos != std::string::npos); | 36 DCHECK(pos != std::string::npos); |
37 if (pos != std::string::npos) { | 37 if (pos != std::string::npos) { |
38 headers_ = headers.substr(pos + 2); | 38 headers_ = headers.substr(pos + 2); |
39 | 39 |
40 StringTokenizer tokenizer(headers.begin(), headers.begin() + pos, " "); | 40 base::StringTokenizer tokenizer(headers.begin(), headers.begin() + pos, " ")
; |
41 std::string* parse[] = { &method_, &path_, &version_ }; | 41 std::string* parse[] = { &method_, &path_, &version_ }; |
42 int field = 0; | 42 int field = 0; |
43 while (tokenizer.GetNext() && field < arraysize(parse)) { | 43 while (tokenizer.GetNext() && field < arraysize(parse)) { |
44 parse[field++]->assign(tokenizer.token_begin(), | 44 parse[field++]->assign(tokenizer.token_begin(), |
45 tokenizer.token_end()); | 45 tokenizer.token_end()); |
46 } | 46 } |
47 } | 47 } |
48 | 48 |
49 // Check for content-length in case we're being sent some data. | 49 // Check for content-length in case we're being sent some data. |
50 net::HttpUtil::HeadersIterator it(headers_.begin(), headers_.end(), | 50 net::HttpUtil::HeadersIterator it(headers_.begin(), headers_.end(), |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 data_.append(content_length_header); | 410 data_.append(content_length_header); |
411 data_.append("\r\n"); | 411 data_.append("\r\n"); |
412 } | 412 } |
413 | 413 |
414 MessageLoop::current()->PostDelayedTask( | 414 MessageLoop::current()->PostDelayedTask( |
415 FROM_HERE, base::Bind(&ConfigurableConnection::SendChunk, this), | 415 FROM_HERE, base::Bind(&ConfigurableConnection::SendChunk, this), |
416 base::TimeDelta::FromMilliseconds(options.timeout_)); | 416 base::TimeDelta::FromMilliseconds(options.timeout_)); |
417 } | 417 } |
418 | 418 |
419 } // namespace test_server | 419 } // namespace test_server |
OLD | NEW |