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/http/http_stream_parser.h" | 5 #include "net/http/http_stream_parser.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
11 #include "base/profiler/scoped_tracker.h" | 11 #include "base/profiler/scoped_tracker.h" |
12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
13 #include "base/values.h" | 13 #include "base/values.h" |
14 #include "net/base/io_buffer.h" | 14 #include "net/base/io_buffer.h" |
15 #include "net/base/ip_endpoint.h" | 15 #include "net/base/ip_endpoint.h" |
16 #include "net/base/upload_data_stream.h" | 16 #include "net/base/upload_data_stream.h" |
17 #include "net/http/http_chunked_decoder.h" | 17 #include "net/http/http_chunked_decoder.h" |
18 #include "net/http/http_request_headers.h" | 18 #include "net/http/http_request_headers.h" |
19 #include "net/http/http_request_info.h" | 19 #include "net/http/http_request_info.h" |
20 #include "net/http/http_response_headers.h" | 20 #include "net/http/http_response_headers.h" |
21 #include "net/http/http_status_line_validator.h" | 21 #include "net/http/http_status_line_validator.h" |
22 #include "net/http/http_util.h" | 22 #include "net/http/http_util.h" |
23 #include "net/socket/client_socket_handle.h" | 23 #include "net/socket/client_socket_handle.h" |
24 #include "net/socket/ssl_client_socket.h" | 24 #include "net/socket/ssl_client_socket.h" |
| 25 #include "net/ssl/token_binding.h" |
25 | 26 |
26 namespace net { | 27 namespace net { |
27 | 28 |
28 namespace { | 29 namespace { |
29 | 30 |
30 enum HttpHeaderParserEvent { | 31 enum HttpHeaderParserEvent { |
31 HEADER_PARSER_INVOKED = 0, | 32 HEADER_PARSER_INVOKED = 0, |
32 // Obsolete: HEADER_HTTP_09_RESPONSE = 1, | 33 // Obsolete: HEADER_HTTP_09_RESPONSE = 1, |
33 HEADER_ALLOWED_TRUNCATED_HEADERS = 2, | 34 HEADER_ALLOWED_TRUNCATED_HEADERS = 2, |
34 HEADER_SKIPPED_WS_PREFIX = 3, | 35 HEADER_SKIPPED_WS_PREFIX = 3, |
(...skipping 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1091 | 1092 |
1092 void HttpStreamParser::GetSSLCertRequestInfo( | 1093 void HttpStreamParser::GetSSLCertRequestInfo( |
1093 SSLCertRequestInfo* cert_request_info) { | 1094 SSLCertRequestInfo* cert_request_info) { |
1094 if (request_->url.SchemeIsCryptographic() && connection_->socket()) { | 1095 if (request_->url.SchemeIsCryptographic() && connection_->socket()) { |
1095 SSLClientSocket* ssl_socket = | 1096 SSLClientSocket* ssl_socket = |
1096 static_cast<SSLClientSocket*>(connection_->socket()); | 1097 static_cast<SSLClientSocket*>(connection_->socket()); |
1097 ssl_socket->GetSSLCertRequestInfo(cert_request_info); | 1098 ssl_socket->GetSSLCertRequestInfo(cert_request_info); |
1098 } | 1099 } |
1099 } | 1100 } |
1100 | 1101 |
| 1102 int HttpStreamParser::GetProvidedTokenBindingWithKey( |
| 1103 const scoped_ptr<crypto::ECPrivateKey>& key, |
| 1104 std::string* header_out) { |
| 1105 if (!request_->url.SchemeIsCryptographic() || !connection_->socket()) { |
| 1106 NOTREACHED(); |
| 1107 return ERR_FAILED; |
| 1108 } |
| 1109 SSLClientSocket* ssl_socket = |
| 1110 static_cast<SSLClientSocket*>(connection_->socket()); |
| 1111 std::vector<uint8_t> signed_ekm; |
| 1112 if (ssl_socket->GetSignedEKMForTokenBinding(key.get(), &signed_ekm) != OK || |
| 1113 BuildProvidedTokenBinding(key.get(), signed_ekm, header_out) != OK) { |
| 1114 return ERR_FAILED; |
| 1115 } |
| 1116 return OK; |
| 1117 } |
| 1118 |
1101 int HttpStreamParser::EncodeChunk(const base::StringPiece& payload, | 1119 int HttpStreamParser::EncodeChunk(const base::StringPiece& payload, |
1102 char* output, | 1120 char* output, |
1103 size_t output_size) { | 1121 size_t output_size) { |
1104 if (output_size < payload.size() + kChunkHeaderFooterSize) | 1122 if (output_size < payload.size() + kChunkHeaderFooterSize) |
1105 return ERR_INVALID_ARGUMENT; | 1123 return ERR_INVALID_ARGUMENT; |
1106 | 1124 |
1107 char* cursor = output; | 1125 char* cursor = output; |
1108 // Add the header. | 1126 // Add the header. |
1109 const int num_chars = base::snprintf(output, output_size, | 1127 const int num_chars = base::snprintf(output, output_size, |
1110 "%X\r\n", | 1128 "%X\r\n", |
(...skipping 27 matching lines...) Expand all Loading... |
1138 } | 1156 } |
1139 | 1157 |
1140 void HttpStreamParser::ValidateStatusLine(const std::string& status_line) { | 1158 void HttpStreamParser::ValidateStatusLine(const std::string& status_line) { |
1141 HttpStatusLineValidator::StatusLineStatus status = | 1159 HttpStatusLineValidator::StatusLineStatus status = |
1142 HttpStatusLineValidator::ValidateStatusLine(status_line); | 1160 HttpStatusLineValidator::ValidateStatusLine(status_line); |
1143 UMA_HISTOGRAM_ENUMERATION("Net.HttpStatusLineStatus", status, | 1161 UMA_HISTOGRAM_ENUMERATION("Net.HttpStatusLineStatus", status, |
1144 HttpStatusLineValidator::STATUS_LINE_MAX); | 1162 HttpStatusLineValidator::STATUS_LINE_MAX); |
1145 } | 1163 } |
1146 | 1164 |
1147 } // namespace net | 1165 } // namespace net |
OLD | NEW |