feat: improve request handling by encapsulating body management and …#2
feat: improve request handling by encapsulating body management and …#2AbdulRehman-z merged 1 commit intomainfrom
Conversation
…y smart buffer management plus updating header retrieval
|
Caution Review failedThe pull request is closed. WalkthroughRemoves slog logging. Adds NewHeaders constructor and GetInt to headers. Refactors request parsing to stream the body using a byte buffer, replaces exported Body with internal fields, and uses Headers.GetInt for content-length. Updates tests to new body handling and adds an error case for length mismatch. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant C as Client
participant R as RequestFromReader
participant P as Parser
participant H as Headers
C->>R: Provide reader stream
R->>P: Initialize parser
loop Read lines
P->>H: Parse header lines
end
H-->>P: content-length via GetInt()
alt content-length == 0 or missing
P->>R: StateDone (no body)
else content-length > 0
P->>P: Allocate bodyBuffer[length], bodyPos=0
loop Until bodyPos == length
C-->>P: Chunk bytes
P->>P: Copy into bodyBuffer, advance bodyPos
end
P->>P: body = string(bodyBuffer)
P->>R: StateDone
end
opt Error path
Note right of P: If stream ends before bodyPos == length
P-->>R: Return error (length mismatch)
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Poem
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. 📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 💡 Knowledge Base configuration:
You can enable these sources in your CodeRabbit configuration. 📒 Files selected for processing (3)
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
…by smart buffer management plus updating header retrieval
Summary by CodeRabbit