| 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/server/http_connection.h" | 5 #include "net/server/http_connection.h" |
| 6 | 6 |
| 7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
| 8 #include "base/stringprintf.h" | 8 #include "base/stringprintf.h" |
| 9 #include "net/server/http_server.h" | 9 #include "net/server/http_server.h" |
| 10 #include "net/server/web_socket.h" | 10 #include "net/server/web_socket.h" |
| 11 #include "net/socket/stream_listen_socket.h" | 11 #include "net/socket/stream_listen_socket.h" |
| 12 | 12 |
| 13 namespace net { | 13 namespace net { |
| 14 | 14 |
| 15 int HttpConnection::last_id_ = 0; | 15 int HttpConnection::last_id_ = 0; |
| 16 | 16 |
| 17 void HttpConnection::Send(const std::string& data) { | 17 void HttpConnection::Send(const std::string& data) { |
| 18 if (!socket_) | 18 if (!socket_.get()) |
| 19 return; | 19 return; |
| 20 socket_->Send(data); | 20 socket_->Send(data); |
| 21 } | 21 } |
| 22 | 22 |
| 23 void HttpConnection::Send(const char* bytes, int len) { | 23 void HttpConnection::Send(const char* bytes, int len) { |
| 24 if (!socket_) | 24 if (!socket_.get()) |
| 25 return; | 25 return; |
| 26 socket_->Send(bytes, len); | 26 socket_->Send(bytes, len); |
| 27 } | 27 } |
| 28 | 28 |
| 29 void HttpConnection::Send(HttpStatusCode status_code, | 29 void HttpConnection::Send(HttpStatusCode status_code, |
| 30 const std::string& data, | 30 const std::string& data, |
| 31 const std::string& content_type) { | 31 const std::string& content_type) { |
| 32 if (!socket_) | 32 if (!socket_.get()) |
| 33 return; | 33 return; |
| 34 | 34 |
| 35 std::string status_message; | 35 std::string status_message; |
| 36 switch (status_code) { | 36 switch (status_code) { |
| 37 case HTTP_OK: | 37 case HTTP_OK: |
| 38 status_message = "OK"; | 38 status_message = "OK"; |
| 39 break; | 39 break; |
| 40 case HTTP_NOT_FOUND: | 40 case HTTP_NOT_FOUND: |
| 41 status_message = "Not Found"; | 41 status_message = "Not Found"; |
| 42 break; | 42 break; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 73 | 73 |
| 74 void HttpConnection::DetachSocket() { | 74 void HttpConnection::DetachSocket() { |
| 75 socket_ = NULL; | 75 socket_ = NULL; |
| 76 } | 76 } |
| 77 | 77 |
| 78 void HttpConnection::Shift(int num_bytes) { | 78 void HttpConnection::Shift(int num_bytes) { |
| 79 recv_data_ = recv_data_.substr(num_bytes); | 79 recv_data_ = recv_data_.substr(num_bytes); |
| 80 } | 80 } |
| 81 | 81 |
| 82 } // namespace net | 82 } // namespace net |
| OLD | NEW |