| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/tools/balsa/balsa_frame.h" | 5 #include "net/tools/balsa/balsa_frame.h" |
| 6 | 6 |
| 7 #include <assert.h> | 7 #include <assert.h> |
| 8 #if __SSE2__ | 8 #if __SSE2__ |
| 9 #include <emmintrin.h> | 9 #include <emmintrin.h> |
| 10 #endif // __SSE2__ | 10 #endif // __SSE2__ |
| (...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 738 value.remove_suffix(1); | 738 value.remove_suffix(1); |
| 739 } | 739 } |
| 740 | 740 |
| 741 extensions->AppendHeader(key, value); | 741 extensions->AppendHeader(key, value); |
| 742 | 742 |
| 743 StringPieceUtils::RemoveWhitespaceContext(&remaining); | 743 StringPieceUtils::RemoveWhitespaceContext(&remaining); |
| 744 SplitStringPiece(remaining, ';', &extension, &remaining); | 744 SplitStringPiece(remaining, ';', &extension, &remaining); |
| 745 } | 745 } |
| 746 } | 746 } |
| 747 | 747 |
| 748 // TODO(phython): Fix this function to properly deal with quoted values. | |
| 749 // E.g. ";;foo", "\";;\"", or \"aa; | |
| 750 // The last example, the semi-colon is a separator between extensions. | |
| 751 void ProcessChunkExtensionsGoogle3(const char* input, size_t size, | |
| 752 BalsaHeaders* extensions) { | |
| 753 std::vector<base::StringPiece> key_values; | |
| 754 SplitStringPieceToVector(base::StringPiece(input, size), ";", | |
| 755 &key_values, true); | |
| 756 for (unsigned int i = 0; i < key_values.size(); ++i) { | |
| 757 base::StringPiece key = key_values[i].substr(0, key_values[i].find('=')); | |
| 758 base::StringPiece value; | |
| 759 if (key.length() < key_values[i].length()) { | |
| 760 value = key_values[i].substr(key.length() + 1); | |
| 761 // Remove any leading and trailing whitespace. | |
| 762 StringPieceUtils::RemoveWhitespaceContext(&value); | |
| 763 | |
| 764 // Strip quotation marks if they exist. | |
| 765 if (!value.empty() && value[0] == '"') | |
| 766 value.remove_prefix(1); | |
| 767 if (!value.empty() && value[value.length() - 1] == '"') | |
| 768 value.remove_suffix(1); | |
| 769 } | |
| 770 | |
| 771 // Strip the key whitespace after checking that there is a value. | |
| 772 StringPieceUtils::RemoveWhitespaceContext(&key); | |
| 773 extensions->AppendHeader(key, value); | |
| 774 } | |
| 775 } | |
| 776 | |
| 777 } // anonymous namespace | 748 } // anonymous namespace |
| 778 | 749 |
| 779 void BalsaFrame::ProcessChunkExtensions(const char* input, size_t size, | 750 void BalsaFrame::ProcessChunkExtensions(const char* input, size_t size, |
| 780 BalsaHeaders* extensions) { | 751 BalsaHeaders* extensions) { |
| 781 #if 0 | |
| 782 ProcessChunkExtensionsGoogle3(input, size, extensions); | |
| 783 #else | |
| 784 ProcessChunkExtensionsManual(base::StringPiece(input, size), extensions); | 752 ProcessChunkExtensionsManual(base::StringPiece(input, size), extensions); |
| 785 #endif | |
| 786 } | 753 } |
| 787 | 754 |
| 788 void BalsaFrame::ProcessHeaderLines() { | 755 void BalsaFrame::ProcessHeaderLines() { |
| 789 HeaderLines::size_type content_length_idx = 0; | 756 HeaderLines::size_type content_length_idx = 0; |
| 790 HeaderLines::size_type transfer_encoding_idx = 0; | 757 HeaderLines::size_type transfer_encoding_idx = 0; |
| 791 | 758 |
| 792 DCHECK(!lines_.empty()); | 759 DCHECK(!lines_.empty()); |
| 793 #if DEBUGFRAMER | 760 #if DEBUGFRAMER |
| 794 LOG(INFO) << "******@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@**********\n"; | 761 LOG(INFO) << "******@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@**********\n"; |
| 795 #endif // DEBUGFRAMER | 762 #endif // DEBUGFRAMER |
| (...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1588 #endif // DEBUGFRAMER | 1555 #endif // DEBUGFRAMER |
| 1589 return current - input; | 1556 return current - input; |
| 1590 } | 1557 } |
| 1591 | 1558 |
| 1592 const uint32 BalsaFrame::kValidTerm1; | 1559 const uint32 BalsaFrame::kValidTerm1; |
| 1593 const uint32 BalsaFrame::kValidTerm1Mask; | 1560 const uint32 BalsaFrame::kValidTerm1Mask; |
| 1594 const uint32 BalsaFrame::kValidTerm2; | 1561 const uint32 BalsaFrame::kValidTerm2; |
| 1595 const uint32 BalsaFrame::kValidTerm2Mask; | 1562 const uint32 BalsaFrame::kValidTerm2Mask; |
| 1596 | 1563 |
| 1597 } // namespace net | 1564 } // namespace net |
| OLD | NEW |