Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jun 2, 2025

  • Analyze current HttpRequest/HttpMessage structure
  • Add mutable attachment parameter to HttpMessage.Request
  • Add attachment accessor methods to HttpMessage trait
  • Ensure attachment is preserved when copying requests
  • Create focused tests for attachment functionality
  • Validate that existing functionality remains unchanged
  • Test build and lint

The goal is to support adding context parameters (RPC context, logging context) to HTTP requests using a mutable attachment system while maintaining immutability for other request parameters.

Fixes #3880.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@Copilot Copilot AI assigned Copilot and xerial Jun 2, 2025
xerial added a commit that referenced this pull request Jul 19, 2025
Adds a mutable attachment field to HttpMessage.Request to allow attaching context
information (RPC context, logging context, authorized user info) that travels with
the request. This replaces unreliable thread-local storage approaches.

Key changes:
- Add ConcurrentHashMap-based attachment storage to Request
- Provide type-safe getter/setter methods for attachments
- Ensure attachments are preserved when copying requests
- Comprehensive test coverage for all attachment operations

The case class parameters remain immutable; only the attachment map is mutable.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
xerial added a commit that referenced this pull request Jul 19, 2025
## Summary
- Adds a mutable attachment field to `HttpMessage.Request` to allow
attaching context information (RPC context, logging context, authorized
user info) that travels with the request
- Replaces unreliable thread-local storage approaches with
request-scoped attachments
- Implements issue #3952

## Key changes
- Add `ConcurrentHashMap`-based attachment storage to Request class
- Provide type-safe getter/setter methods for managing attachments
- Ensure attachments are preserved when copying requests (using Scala's
`++=` operator)
- Add comprehensive test coverage for all attachment operations

## Implementation details
- The case class parameters remain immutable; only the attachment map is
mutable
- Uses `ConcurrentHashMap` for thread-safe concurrent access
- Attachments are automatically copied when creating modified requests
via `withX` methods

## Test plan
✅ Unit tests added for:
- Basic get/set/remove operations
- Attachment preservation during request copying
- Concurrent access safety
- Complex attachment types support

All tests pass successfully.

🤖 Generated with [Claude Code](https://claude.ai/code)

---------

Co-authored-by: Claude <noreply@anthropic.com>
@xerial xerial closed this Jul 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

http (feature): Support adding attachment to the request
2 participants