| 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 "chrome_frame/test/test_server.h" |
| 6 |
| 5 #include <windows.h> | 7 #include <windows.h> |
| 6 #include <objbase.h> | 8 #include <objbase.h> |
| 7 #include <urlmon.h> | 9 #include <urlmon.h> |
| 8 | 10 |
| 9 #include "base/bind.h" | 11 #include "base/bind.h" |
| 10 #include "base/logging.h" | 12 #include "base/logging.h" |
| 11 #include "base/string_number_conversions.h" | 13 #include "base/string_number_conversions.h" |
| 12 #include "base/string_piece.h" | 14 #include "base/string_piece.h" |
| 13 #include "base/string_util.h" | 15 #include "base/string_util.h" |
| 14 #include "base/stringprintf.h" | 16 #include "base/stringprintf.h" |
| 15 #include "base/utf_string_conversions.h" | 17 #include "base/utf_string_conversions.h" |
| 16 #include "chrome_frame/test/chrome_frame_test_utils.h" | 18 #include "chrome_frame/test/chrome_frame_test_utils.h" |
| 17 #include "chrome_frame/test/test_server.h" | |
| 18 #include "net/base/tcp_listen_socket.h" | 19 #include "net/base/tcp_listen_socket.h" |
| 19 #include "net/base/winsock_init.h" | 20 #include "net/base/winsock_init.h" |
| 20 #include "net/http/http_util.h" | 21 #include "net/http/http_util.h" |
| 21 | 22 |
| 22 namespace test_server { | 23 namespace test_server { |
| 23 const char kDefaultHeaderTemplate[] = | 24 const char kDefaultHeaderTemplate[] = |
| 24 "HTTP/1.1 %hs\r\n" | 25 "HTTP/1.1 %hs\r\n" |
| 25 "Connection: close\r\n" | 26 "Connection: close\r\n" |
| 26 "Content-Type: %hs\r\n" | 27 "Content-Type: %hs\r\n" |
| 27 "Content-Length: %i\r\n\r\n"; | 28 "Content-Length: %i\r\n\r\n"; |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 void FileResponse::WriteContents(net::StreamListenSocket* socket) const { | 111 void FileResponse::WriteContents(net::StreamListenSocket* socket) const { |
| 111 DCHECK(file_.get()); | 112 DCHECK(file_.get()); |
| 112 if (file_.get()) { | 113 if (file_.get()) { |
| 113 socket->Send(reinterpret_cast<const char*>(file_->data()), | 114 socket->Send(reinterpret_cast<const char*>(file_->data()), |
| 114 file_->length(), false); | 115 file_->length(), false); |
| 115 } | 116 } |
| 116 } | 117 } |
| 117 | 118 |
| 118 size_t FileResponse::ContentLength() const { | 119 size_t FileResponse::ContentLength() const { |
| 119 if (file_.get() == NULL) { | 120 if (file_.get() == NULL) { |
| 120 file_.reset(new file_util::MemoryMappedFile()); | 121 file_.reset(new base::MemoryMappedFile()); |
| 121 if (!file_->Initialize(file_path_)) { | 122 if (!file_->Initialize(file_path_)) { |
| 122 NOTREACHED(); | 123 NOTREACHED(); |
| 123 file_.reset(); | 124 file_.reset(); |
| 124 } | 125 } |
| 125 } | 126 } |
| 126 return file_.get() ? file_->length() : 0; | 127 return file_.get() ? file_->length() : 0; |
| 127 } | 128 } |
| 128 | 129 |
| 129 bool RedirectResponse::GetCustomHeaders(std::string* headers) const { | 130 bool RedirectResponse::GetCustomHeaders(std::string* headers) const { |
| 130 *headers = base::StringPrintf("HTTP/1.1 302 Found\r\n" | 131 *headers = base::StringPrintf("HTTP/1.1 302 Found\r\n" |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 data_.append(content_length_header); | 411 data_.append(content_length_header); |
| 411 data_.append("\r\n"); | 412 data_.append("\r\n"); |
| 412 } | 413 } |
| 413 | 414 |
| 414 MessageLoop::current()->PostDelayedTask( | 415 MessageLoop::current()->PostDelayedTask( |
| 415 FROM_HERE, base::Bind(&ConfigurableConnection::SendChunk, this), | 416 FROM_HERE, base::Bind(&ConfigurableConnection::SendChunk, this), |
| 416 base::TimeDelta::FromMilliseconds(options.timeout_)); | 417 base::TimeDelta::FromMilliseconds(options.timeout_)); |
| 417 } | 418 } |
| 418 | 419 |
| 419 } // namespace test_server | 420 } // namespace test_server |
| OLD | NEW |