| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // TODO(ukai): code is similar with http_network_transaction.cc. We should | 5 // TODO(ukai): code is similar with http_network_transaction.cc. We should |
| 6 // think about ways to share code, if possible. | 6 // think about ways to share code, if possible. |
| 7 | 7 |
| 8 #include "net/socket_stream/socket_stream.h" | 8 #include "net/socket_stream/socket_stream.h" |
| 9 | 9 |
| 10 #include <set> | 10 #include <set> |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/message_loop.h" | 15 #include "base/message_loop.h" |
| 16 #include "base/string_util.h" | 16 #include "base/string_util.h" |
| 17 #include "base/stringprintf.h" |
| 17 #include "base/utf_string_conversions.h" | 18 #include "base/utf_string_conversions.h" |
| 18 #include "net/base/auth.h" | 19 #include "net/base/auth.h" |
| 19 #include "net/base/host_resolver.h" | 20 #include "net/base/host_resolver.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/net_util.h" | 23 #include "net/base/net_util.h" |
| 23 #include "net/http/http_auth_handler_factory.h" | 24 #include "net/http/http_auth_handler_factory.h" |
| 24 #include "net/http/http_request_info.h" | 25 #include "net/http/http_request_info.h" |
| 25 #include "net/http/http_response_headers.h" | 26 #include "net/http/http_response_headers.h" |
| 26 #include "net/http/http_util.h" | 27 #include "net/http/http_util.h" |
| 27 #include "net/socket/client_socket_factory.h" | 28 #include "net/socket/client_socket_factory.h" |
| 28 #include "net/socket/ssl_client_socket.h" | |
| 29 #include "net/socket/socks5_client_socket.h" | 29 #include "net/socket/socks5_client_socket.h" |
| 30 #include "net/socket/socks_client_socket.h" | 30 #include "net/socket/socks_client_socket.h" |
| 31 #include "net/socket/ssl_client_socket.h" |
| 31 #include "net/socket/tcp_client_socket.h" | 32 #include "net/socket/tcp_client_socket.h" |
| 32 #include "net/socket_stream/socket_stream_metrics.h" | 33 #include "net/socket_stream/socket_stream_metrics.h" |
| 33 #include "net/url_request/url_request.h" | 34 #include "net/url_request/url_request.h" |
| 34 | 35 |
| 35 static const int kMaxPendingSendAllowed = 32768; // 32 kilobytes. | 36 static const int kMaxPendingSendAllowed = 32768; // 32 kilobytes. |
| 36 static const int kReadBufferSize = 4096; | 37 static const int kReadBufferSize = 4096; |
| 37 | 38 |
| 38 namespace net { | 39 namespace net { |
| 39 | 40 |
| 40 SocketStream::ResponseHeaders::ResponseHeaders() : IOBuffer() {} | 41 SocketStream::ResponseHeaders::ResponseHeaders() : IOBuffer() {} |
| (...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 618 &auth_token); | 619 &auth_token); |
| 619 // TODO(cbentzel): Support async auth handlers. | 620 // TODO(cbentzel): Support async auth handlers. |
| 620 DCHECK_NE(ERR_IO_PENDING, rv); | 621 DCHECK_NE(ERR_IO_PENDING, rv); |
| 621 if (rv != OK) | 622 if (rv != OK) |
| 622 return rv; | 623 return rv; |
| 623 authorization_headers.append( | 624 authorization_headers.append( |
| 624 HttpAuth::GetAuthorizationHeaderName(HttpAuth::AUTH_PROXY) + | 625 HttpAuth::GetAuthorizationHeaderName(HttpAuth::AUTH_PROXY) + |
| 625 ": " + auth_token + "\r\n"); | 626 ": " + auth_token + "\r\n"); |
| 626 } | 627 } |
| 627 | 628 |
| 628 tunnel_request_headers_->headers_ = StringPrintf( | 629 tunnel_request_headers_->headers_ = base::StringPrintf( |
| 629 "CONNECT %s HTTP/1.1\r\n" | 630 "CONNECT %s HTTP/1.1\r\n" |
| 630 "Host: %s\r\n" | 631 "Host: %s\r\n" |
| 631 "Proxy-Connection: keep-alive\r\n", | 632 "Proxy-Connection: keep-alive\r\n", |
| 632 GetHostAndPort(url_).c_str(), | 633 GetHostAndPort(url_).c_str(), |
| 633 GetHostAndOptionalPort(url_).c_str()); | 634 GetHostAndOptionalPort(url_).c_str()); |
| 634 if (!authorization_headers.empty()) | 635 if (!authorization_headers.empty()) |
| 635 tunnel_request_headers_->headers_ += authorization_headers; | 636 tunnel_request_headers_->headers_ += authorization_headers; |
| 636 tunnel_request_headers_->headers_ += "\r\n"; | 637 tunnel_request_headers_->headers_ += "\r\n"; |
| 637 } | 638 } |
| 638 tunnel_request_headers_->SetDataOffset(tunnel_request_headers_bytes_sent_); | 639 tunnel_request_headers_->SetDataOffset(tunnel_request_headers_bytes_sent_); |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1016 | 1017 |
| 1017 SSLConfigService* SocketStream::ssl_config_service() const { | 1018 SSLConfigService* SocketStream::ssl_config_service() const { |
| 1018 return context_->ssl_config_service(); | 1019 return context_->ssl_config_service(); |
| 1019 } | 1020 } |
| 1020 | 1021 |
| 1021 ProxyService* SocketStream::proxy_service() const { | 1022 ProxyService* SocketStream::proxy_service() const { |
| 1022 return context_->proxy_service(); | 1023 return context_->proxy_service(); |
| 1023 } | 1024 } |
| 1024 | 1025 |
| 1025 } // namespace net | 1026 } // namespace net |
| OLD | NEW |