| 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 #ifndef NET_TOOLS_BALSA_BALSA_HEADERS_H_ | 5 #ifndef NET_TOOLS_BALSA_BALSA_HEADERS_H_ |
| 6 #define NET_TOOLS_BALSA_BALSA_HEADERS_H_ | 6 #define NET_TOOLS_BALSA_BALSA_HEADERS_H_ |
| 7 | 7 |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <iosfwd> | 9 #include <iosfwd> |
| 10 #include <iterator> | 10 #include <iterator> |
| (...skipping 800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 811 if (!key.empty()) { | 811 if (!key.empty()) { |
| 812 buffer->Write(key.data(), key.size()); | 812 buffer->Write(key.data(), key.size()); |
| 813 buffer->Write(": ", 2); | 813 buffer->Write(": ", 2); |
| 814 buffer->Write(value.data(), value.size()); | 814 buffer->Write(value.data(), value.size()); |
| 815 buffer->Write("\r\n", 2); | 815 buffer->Write("\r\n", 2); |
| 816 } | 816 } |
| 817 } | 817 } |
| 818 | 818 |
| 819 // Dump the textural representation of the header object to a string, which | 819 // Dump the textural representation of the header object to a string, which |
| 820 // is suitable for writing out to logs. All CRLF will be printed out as \n. | 820 // is suitable for writing out to logs. All CRLF will be printed out as \n. |
| 821 // This function can be called on a header object in any state. Raw header | 821 // This function can be called on a header object in any state. The header |
| 822 // data will be printed out if the header object is not completely parsed, | 822 // content is appended to the string; the original content is not cleared. |
| 823 // e.g., when there was an error in the middle of parsing. | 823 void DumpHeadersToString(std::string* str) const; |
| 824 // The header content is appended to the string; the original content is not | 824 |
| 825 // cleared. | 825 // Calls DumpHeadersToString to dump the textural representation of the header |
| 826 // object to a string. Raw header data will be printed out if the header |
| 827 // object is not completely parsed, e.g., when there was an error in the |
| 828 // middle of parsing. |
| 826 void DumpToString(std::string* str) const; | 829 void DumpToString(std::string* str) const; |
| 827 | 830 |
| 828 const base::StringPiece first_line() const { | 831 const base::StringPiece first_line() const { |
| 829 DCHECK_GE(whitespace_4_idx_, non_whitespace_1_idx_); | 832 DCHECK_GE(whitespace_4_idx_, non_whitespace_1_idx_); |
| 830 return base::StringPiece(BeginningOfFirstLine() + non_whitespace_1_idx_, | 833 return base::StringPiece(BeginningOfFirstLine() + non_whitespace_1_idx_, |
| 831 whitespace_4_idx_ - non_whitespace_1_idx_); | 834 whitespace_4_idx_ - non_whitespace_1_idx_); |
| 832 } | 835 } |
| 833 | 836 |
| 834 // Returns the parsed value of the response code if it has been parsed. | 837 // Returns the parsed value of the response code if it has been parsed. |
| 835 // Guaranteed to return 0 when unparsed (though it is a much better idea to | 838 // Guaranteed to return 0 when unparsed (though it is a much better idea to |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1129 size_t end_of_firstline_idx_; | 1132 size_t end_of_firstline_idx_; |
| 1130 | 1133 |
| 1131 bool transfer_encoding_is_chunked_; | 1134 bool transfer_encoding_is_chunked_; |
| 1132 | 1135 |
| 1133 HeaderLines header_lines_; | 1136 HeaderLines header_lines_; |
| 1134 }; | 1137 }; |
| 1135 | 1138 |
| 1136 } // namespace net | 1139 } // namespace net |
| 1137 | 1140 |
| 1138 #endif // NET_TOOLS_BALSA_BALSA_HEADERS_H_ | 1141 #endif // NET_TOOLS_BALSA_BALSA_HEADERS_H_ |
| OLD | NEW |