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 #include "net/tools/flip_server/balsa_headers.h" | 5 #include "net/tools/flip_server/balsa_headers.h" |
6 | 6 |
7 #include <emmintrin.h> | 7 #include <emmintrin.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <ext/hash_set> | 10 #include <ext/hash_set> |
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 OriginalHeaderStreamEnd() - OriginalHeaderStreamBegin(); | 548 OriginalHeaderStreamEnd() - OriginalHeaderStreamBegin(); |
549 // First check whether the header object is empty. | 549 // First check whether the header object is empty. |
550 if (firstline.empty() && buffer_length == 0) { | 550 if (firstline.empty() && buffer_length == 0) { |
551 str->append("\n<empty header>\n"); | 551 str->append("\n<empty header>\n"); |
552 return; | 552 return; |
553 } | 553 } |
554 | 554 |
555 // Then check whether the header is in a partially parsed state. If so, just | 555 // Then check whether the header is in a partially parsed state. If so, just |
556 // dump the raw data. | 556 // dump the raw data. |
557 if (balsa_buffer_.can_write_to_contiguous_buffer()) { | 557 if (balsa_buffer_.can_write_to_contiguous_buffer()) { |
558 StringAppendF(str, "\n<incomplete header len: %d>\n%.*s\n", | 558 base::StringAppendF(str, "\n<incomplete header len: %d>\n%.*s\n", |
559 buffer_length, buffer_length, OriginalHeaderStreamBegin()); | 559 buffer_length, buffer_length, |
| 560 OriginalHeaderStreamBegin()); |
560 return; | 561 return; |
561 } | 562 } |
562 | 563 |
563 // If the header is complete, then just dump them with the logical key value | 564 // If the header is complete, then just dump them with the logical key value |
564 // pair. | 565 // pair. |
565 str->reserve(str->size() + GetSizeForWriteBuffer()); | 566 str->reserve(str->size() + GetSizeForWriteBuffer()); |
566 StringAppendF(str, "\n %.*s\n", | 567 base::StringAppendF(str, "\n %.*s\n", |
567 static_cast<int>(firstline.size()), | 568 static_cast<int>(firstline.size()), |
568 firstline.data()); | 569 firstline.data()); |
569 BalsaHeaders::const_header_lines_iterator i = header_lines_begin(); | 570 BalsaHeaders::const_header_lines_iterator i = header_lines_begin(); |
570 for (; i != header_lines_end(); ++i) { | 571 for (; i != header_lines_end(); ++i) { |
571 StringAppendF(str, " %.*s: %.*s\n", | 572 base::StringAppendF(str, " %.*s: %.*s\n", |
572 static_cast<int>(i->first.size()), i->first.data(), | 573 static_cast<int>(i->first.size()), i->first.data(), |
573 static_cast<int>(i->second.size()), i->second.data()); | 574 static_cast<int>(i->second.size()), i->second.data()); |
574 } | 575 } |
575 } | 576 } |
576 | 577 |
577 void BalsaHeaders::SetFirstLine(const base::StringPiece& line) { | 578 void BalsaHeaders::SetFirstLine(const base::StringPiece& line) { |
578 base::StringPiece new_line = balsa_buffer_.Write(line, | 579 base::StringPiece new_line = balsa_buffer_.Write(line, |
579 &firstline_buffer_base_idx_); | 580 &firstline_buffer_base_idx_); |
580 whitespace_1_idx_ = new_line.data() - GetPtr(firstline_buffer_base_idx_); | 581 whitespace_1_idx_ = new_line.data() - GetPtr(firstline_buffer_base_idx_); |
581 non_whitespace_1_idx_ = whitespace_1_idx_; | 582 non_whitespace_1_idx_ = whitespace_1_idx_; |
582 whitespace_4_idx_ = whitespace_1_idx_ + line.size(); | 583 whitespace_4_idx_ = whitespace_1_idx_ + line.size(); |
583 whitespace_2_idx_ = whitespace_4_idx_; | 584 whitespace_2_idx_ = whitespace_4_idx_; |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
754 | 755 |
755 void BalsaHeaders::SetResponseReasonPhrase(const base::StringPiece& reason) { | 756 void BalsaHeaders::SetResponseReasonPhrase(const base::StringPiece& reason) { |
756 // Note: There is no difference between request_version() and | 757 // Note: There is no difference between request_version() and |
757 // response_reason_phrase(). Thus, a function to set one is equivalent to a | 758 // response_reason_phrase(). Thus, a function to set one is equivalent to a |
758 // function to set the other. We maintain two functions for this as it is | 759 // function to set the other. We maintain two functions for this as it is |
759 // much more descriptive, and makes code more understandable. | 760 // much more descriptive, and makes code more understandable. |
760 SetRequestVersion(reason); | 761 SetRequestVersion(reason); |
761 } | 762 } |
762 | 763 |
763 } // namespace net | 764 } // namespace net |
OLD | NEW |