| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "mojo/services/network/http_connection_impl.h" | 5 #include "mojo/services/network/http_connection_impl.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 std::string content_type; | 368 std::string content_type; |
| 369 for (size_t i = 0; i < response->headers.size(); ++i) { | 369 for (size_t i = 0; i < response->headers.size(); ++i) { |
| 370 const HttpHeader& header = *(response->headers[i]); | 370 const HttpHeader& header = *(response->headers[i]); |
| 371 | 371 |
| 372 if (body) { | 372 if (body) { |
| 373 // net::HttpServerResponseInfo::SetBody() automatically sets | 373 // net::HttpServerResponseInfo::SetBody() automatically sets |
| 374 // Content-Length and Content-Types, so skip the two here. | 374 // Content-Length and Content-Types, so skip the two here. |
| 375 // | 375 // |
| 376 // TODO(yzshen): Consider adding to net::HttpServerResponseInfo a simple | 376 // TODO(yzshen): Consider adding to net::HttpServerResponseInfo a simple |
| 377 // setter for body which doesn't fiddle with headers. | 377 // setter for body which doesn't fiddle with headers. |
| 378 if (base::strcasecmp(header.name.data(), | 378 base::StringPiece name_piece(header.name.data(), header.name.size()); |
| 379 net::HttpRequestHeaders::kContentLength) == 0) { | 379 if (base::EqualsCaseInsensitiveASCII( |
| 380 name_piece, net::HttpRequestHeaders::kContentLength)) { |
| 380 continue; | 381 continue; |
| 381 } else if (base::strcasecmp(header.name.data(), | 382 } else if (base::EqualsCaseInsensitiveASCII( |
| 382 net::HttpRequestHeaders::kContentType) == 0) { | 383 name_piece, net::HttpRequestHeaders::kContentType)) { |
| 383 content_type = header.value; | 384 content_type = header.value; |
| 384 continue; | 385 continue; |
| 385 } | 386 } |
| 386 } | 387 } |
| 387 info.AddHeader(header.name, header.value); | 388 info.AddHeader(header.name, header.value); |
| 388 } | 389 } |
| 389 | 390 |
| 390 if (body) | 391 if (body) |
| 391 info.SetBody(*body, content_type); | 392 info.SetBody(*body, content_type); |
| 392 | 393 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 // The close operation is initiated by this object. | 425 // The close operation is initiated by this object. |
| 425 NotifyOwnerCloseIfAllDone(); | 426 NotifyOwnerCloseIfAllDone(); |
| 426 } else { | 427 } else { |
| 427 // The close operation is initiated by |web_socket_|; start closing this | 428 // The close operation is initiated by |web_socket_|; start closing this |
| 428 // object. | 429 // object. |
| 429 Close(); | 430 Close(); |
| 430 } | 431 } |
| 431 } | 432 } |
| 432 | 433 |
| 433 } // namespace mojo | 434 } // namespace mojo |
| OLD | NEW |