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/spdy/spdy_framer.h" | 5 #include "net/spdy/spdy_framer.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <cctype> | 10 #include <cctype> |
(...skipping 1641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1652 return false; | 1652 return false; |
1653 } | 1653 } |
1654 const char* begin = temp.data(); | 1654 const char* begin = temp.data(); |
1655 const char* end = begin; | 1655 const char* end = begin; |
1656 std::advance(end, temp.size()); | 1656 std::advance(end, temp.size()); |
1657 if (std::any_of(begin, end, isupper)) { | 1657 if (std::any_of(begin, end, isupper)) { |
1658 DVLOG(1) << "Malformed header: Header name " << temp | 1658 DVLOG(1) << "Malformed header: Header name " << temp |
1659 << " contains upper-case characters."; | 1659 << " contains upper-case characters."; |
1660 return false; | 1660 return false; |
1661 } | 1661 } |
1662 std::string name = temp.as_string(); | 1662 std::string name(temp); |
1663 | 1663 |
1664 // Read header value. | 1664 // Read header value. |
1665 if (!reader.ReadStringPiece32(&temp)) { | 1665 if (!reader.ReadStringPiece32(&temp)) { |
1666 DVLOG(1) << "Unable to read header value (" << index + 1 << " of " | 1666 DVLOG(1) << "Unable to read header value (" << index + 1 << " of " |
1667 << num_headers << ")."; | 1667 << num_headers << ")."; |
1668 return false; | 1668 return false; |
1669 } | 1669 } |
1670 std::string value = temp.as_string(); | 1670 std::string value(temp); |
1671 | 1671 |
1672 // Ensure no duplicates. | 1672 // Ensure no duplicates. |
1673 if (block->find(name) != block->end()) { | 1673 if (block->find(name) != block->end()) { |
1674 DVLOG(1) << "Duplicate header '" << name << "' (" << index + 1 << " of " | 1674 DVLOG(1) << "Duplicate header '" << name << "' (" << index + 1 << " of " |
1675 << num_headers << ")."; | 1675 << num_headers << ")."; |
1676 return false; | 1676 return false; |
1677 } | 1677 } |
1678 | 1678 |
1679 // Store header. | 1679 // Store header. |
1680 (*block)[name] = value; | 1680 (*block)[name] = value; |
(...skipping 1188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2869 builder->WriteUInt32(header_block.size()); | 2869 builder->WriteUInt32(header_block.size()); |
2870 | 2870 |
2871 // Serialize each header. | 2871 // Serialize each header. |
2872 for (const auto& header : header_block) { | 2872 for (const auto& header : header_block) { |
2873 builder->WriteStringPiece32(base::ToLowerASCII(header.first)); | 2873 builder->WriteStringPiece32(base::ToLowerASCII(header.first)); |
2874 builder->WriteStringPiece32(header.second); | 2874 builder->WriteStringPiece32(header.second); |
2875 } | 2875 } |
2876 } | 2876 } |
2877 | 2877 |
2878 } // namespace net | 2878 } // namespace net |
OLD | NEW |