OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_FLIP_SERVER_BALSA_HEADERS_H_ | 5 #ifndef NET_TOOLS_FLIP_SERVER_BALSA_HEADERS_H_ |
6 #define NET_TOOLS_FLIP_SERVER_BALSA_HEADERS_H_ | 6 #define NET_TOOLS_FLIP_SERVER_BALSA_HEADERS_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <iosfwd> | 10 #include <iosfwd> |
(...skipping 798 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
809 // append additional header lines to the header without copying the header. | 809 // append additional header lines to the header without copying the header. |
810 // When the user is done with appending to the buffer, | 810 // When the user is done with appending to the buffer, |
811 // WriteHeaderEndingToBuffer must be used to terminate the HTTP | 811 // WriteHeaderEndingToBuffer must be used to terminate the HTTP |
812 // header in the buffer. This method is a no-op if key is empty. | 812 // header in the buffer. This method is a no-op if key is empty. |
813 template <typename Buffer> | 813 template <typename Buffer> |
814 static void WriteHeaderLineToBuffer(Buffer* buffer, | 814 static void WriteHeaderLineToBuffer(Buffer* buffer, |
815 const base::StringPiece& key, | 815 const base::StringPiece& key, |
816 const base::StringPiece& value) { | 816 const base::StringPiece& value) { |
817 // if the key is empty, we don't want to write the rest because it | 817 // if the key is empty, we don't want to write the rest because it |
818 // will not be a well-formed header line. | 818 // will not be a well-formed header line. |
819 if (key.size() > 0) { | 819 if (!key.empty()) { |
820 buffer->Write(key.data(), key.size()); | 820 buffer->Write(key.data(), key.size()); |
821 buffer->Write(": ", 2); | 821 buffer->Write(": ", 2); |
822 buffer->Write(value.data(), value.size()); | 822 buffer->Write(value.data(), value.size()); |
823 buffer->Write("\r\n", 2); | 823 buffer->Write("\r\n", 2); |
824 } | 824 } |
825 } | 825 } |
826 | 826 |
827 // Dump the textural representation of the header object to a string, which | 827 // Dump the textural representation of the header object to a string, which |
828 // is suitable for writing out to logs. All CRLF will be printed out as \n. | 828 // is suitable for writing out to logs. All CRLF will be printed out as \n. |
829 // This function can be called on a header object in any state. Raw header | 829 // This function can be called on a header object in any state. Raw header |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1137 size_t end_of_firstline_idx_; | 1137 size_t end_of_firstline_idx_; |
1138 | 1138 |
1139 bool transfer_encoding_is_chunked_; | 1139 bool transfer_encoding_is_chunked_; |
1140 | 1140 |
1141 HeaderLines header_lines_; | 1141 HeaderLines header_lines_; |
1142 }; | 1142 }; |
1143 | 1143 |
1144 } // namespace net | 1144 } // namespace net |
1145 | 1145 |
1146 #endif // NET_TOOLS_FLIP_SERVER_BALSA_HEADERS_H_ | 1146 #endif // NET_TOOLS_FLIP_SERVER_BALSA_HEADERS_H_ |
OLD | NEW |