feat(http): implement body inspection handler - #736
Vincent Biret (baywet) merged 14 commits into
Conversation
- Add BodyInspectionHandlerOption with inspect_request_body and inspect_response_body flags - Add BodyInspectionHandler middleware to non-destructively inspect request and response bodies - Provide byte accessors and rewound BytesIO stream helpers - Register BodyInspectionHandler in KiotaClientFactory default middleware pipeline - Add comprehensive unit tests covering options, request/response capture, streaming, and pipeline integration
This comment was marked as outdated.
This comment was marked as outdated.
|
RKS (@rksharma-owg) would you mind addressing the copilot comments please? |
|
Addressed the review findings in ee0ea54: standardized the telemetry key, preserved per-request options across redirects, restored replayable raw response streams after inspection, and added regressions for each behavior. The full Python 3.10-3.14 fork preflight passed, and the linked documentation update is MicrosoftDocs/openapi-docs#175. |
|
Addressed the new review in 1dc4c07. Reused per-request options now clear stale captures, and already-buffered responses retain their original consumed/closed raw-stream state. The request-stream concern was verified against HTTPX 0.25.0-0.28.1 and is already handled by |
|
Addressed both findings from the latest Copilot review in
Local validation is green ( |
|
Thanks for the extra pass — both moderate findings are addressed in |
…n-handler # Conflicts: # packages/http/httpx/kiota_http/middleware/redirect_handler.py
… request.options in redirect handler
…dlers in favor of request extensions
|
RKS (@rksharma-owg) can you run the formatting command please? |
|
okay |
There was a problem hiding this comment.
🔵 Needs a closer look
The change set touches core request/response streaming semantics and migrates the per-request options mechanism, which is subtle and warrants final human verification for compatibility expectations.
Review details
- Files reviewed: 16/16 changed files
- Comments generated: 1
- Review effort level: Lite
|
|
Done, I ran the repository formatting command (
|
Vincent Biret (baywet)
left a comment
There was a problem hiding this comment.
Thank you for making the changes!



Resolves #418
Description
Implements the
BodyInspectionHandlermiddleware andBodyInspectionHandlerOptionfor Kiota Python, following the shared middleware specification in microsoftgraph/msgraph-sdk-design#116.Summary of Changes
BytesIOaccessors.BodyInspectionHandlerin the default middleware pipeline.TypeErrorbefore option or span access.com.microsoft.kiota.handler.bodyInspection.enabletelemetry attribute and keeps the span open through inspection, transport execution, response handling, and exception cleanup.Documentation
Verification
pytestinpackages/http/httpx: 154 passed.suggestion-modeconfiguration warning.eaa50db: https://github.com/rksharma-owg/kiota-python/actions/runs/35131242553eaa50db.