| 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_headers.h" | 5 #include "net/tools/balsa/balsa_headers.h" |
| 6 | 6 |
| 7 #include <stdio.h> | 7 #include <stdio.h> |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 764 | 764 |
| 765 // Then check whether the header is in a partially parsed state. If so, just | 765 // Then check whether the header is in a partially parsed state. If so, just |
| 766 // dump the raw data. | 766 // dump the raw data. |
| 767 if (balsa_buffer_.can_write_to_contiguous_buffer()) { | 767 if (balsa_buffer_.can_write_to_contiguous_buffer()) { |
| 768 base::StringAppendF(str, "\n<incomplete header len: %d>\n%.*s\n", | 768 base::StringAppendF(str, "\n<incomplete header len: %d>\n%.*s\n", |
| 769 buffer_length, buffer_length, | 769 buffer_length, buffer_length, |
| 770 OriginalHeaderStreamBegin()); | 770 OriginalHeaderStreamBegin()); |
| 771 return; | 771 return; |
| 772 } | 772 } |
| 773 | 773 |
| 774 DumpHeadersToString(str); |
| 775 } |
| 776 |
| 777 void BalsaHeaders::DumpHeadersToString(std::string* str) const { |
| 778 const base::StringPiece firstline = first_line(); |
| 774 // If the header is complete, then just dump them with the logical key value | 779 // If the header is complete, then just dump them with the logical key value |
| 775 // pair. | 780 // pair. |
| 776 str->reserve(str->size() + GetSizeForWriteBuffer()); | 781 str->reserve(str->size() + GetSizeForWriteBuffer()); |
| 777 base::StringAppendF(str, "\n %.*s\n", | 782 base::StringAppendF(str, "\n %.*s\n", |
| 778 static_cast<int>(firstline.size()), | 783 static_cast<int>(firstline.size()), |
| 779 firstline.data()); | 784 firstline.data()); |
| 780 BalsaHeaders::const_header_lines_iterator i = header_lines_begin(); | 785 BalsaHeaders::const_header_lines_iterator i = header_lines_begin(); |
| 781 for (; i != header_lines_end(); ++i) { | 786 for (; i != header_lines_end(); ++i) { |
| 782 base::StringAppendF(str, " %.*s: %.*s\n", | 787 base::StringAppendF(str, " %.*s: %.*s\n", |
| 783 static_cast<int>(i->first.size()), i->first.data(), | 788 static_cast<int>(i->first.size()), i->first.data(), |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 965 | 970 |
| 966 void BalsaHeaders::SetResponseReasonPhrase(const base::StringPiece& reason) { | 971 void BalsaHeaders::SetResponseReasonPhrase(const base::StringPiece& reason) { |
| 967 // Note: There is no difference between request_version() and | 972 // Note: There is no difference between request_version() and |
| 968 // response_reason_phrase(). Thus, a function to set one is equivalent to a | 973 // response_reason_phrase(). Thus, a function to set one is equivalent to a |
| 969 // function to set the other. We maintain two functions for this as it is | 974 // function to set the other. We maintain two functions for this as it is |
| 970 // much more descriptive, and makes code more understandable. | 975 // much more descriptive, and makes code more understandable. |
| 971 SetRequestVersion(reason); | 976 SetRequestVersion(reason); |
| 972 } | 977 } |
| 973 | 978 |
| 974 } // namespace net | 979 } // namespace net |
| OLD | NEW |