Add operator<< with CRLF to LF conversion for fields and messages#183
Closed
Add operator<< with CRLF to LF conversion for fields and messages#183
Conversation
Co-authored-by: vinniefalco <1503976+vinniefalco@users.noreply.github.com>
Co-authored-by: vinniefalco <1503976+vinniefalco@users.noreply.github.com>
Co-authored-by: vinniefalco <1503976+vinniefalco@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Update operator<< for fields and messages
Add operator<< with CRLF to LF conversion for fields and messages
Oct 19, 2025
Collaborator
|
Addressed in #188. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This PR implements
operator<<for HTTP message types (fields,fields_base,request,request_base,response,response_base) with automatic CRLF to LF conversion and removal of trailing CRLF.Problem
Previously, only
fields_basehad anoperator<<that simply output the raw buffer containing CRLF line endings and a trailing CRLF (which marks the end of HTTP headers). This made the output unsuitable for logging, debugging, and display purposes:Solution
This PR modifies the existing
operator<<forfields_baseand adds newoperator<<implementations for all derived types. The new implementation:\r\nsequences are replaced with\nfor standard Unix-style line endings\r\nthat indicates the end of headers is not outputImplementation Details
The core conversion logic is in
fields_base::operator<<:All derived type implementations simply forward to the base implementation to maintain consistency.
Benefits
std::cout,std::ofstream,std::stringstream).buffer()still available for raw accessTesting
Added comprehensive test suite in
test/unit/ostream.cppcovering:Fixes #<issue_number>
Original prompt
Fixes #182
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.