feat(http): implement body inspection handler - #736
Open
RKS (rksharma-owg) wants to merge 1 commit into
Open
RKS (rksharma-owg) wants to merge 1 commit into
RKS (rksharma-owg) wants to merge 1 commit 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 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.



Resolves #418
Description
This pull request implements the
BodyInspectionHandlermiddleware andBodyInspectionHandlerOptionfor Kiota Python (packages/http/httpx), following the HTTP middleware specification in microsoftgraph/msgraph-sdk-design#116 and achieving parity with Kiota .NET and Kiota TypeScript.Summary of Changes
BodyInspectionHandlerOption:inspect_request_body: bool = Falseandinspect_response_body: bool = False(defaulting to disabled per spec).bytes(request_body,get_request_body(),get_response_body()).get_request_body_stream(),get_response_body_stream(),request_body_stream,response_body_stream) returning freshBytesIOcopies rewound to position 0.BodyInspectionHandler:BaseMiddlewareto intercept and non-destructively capture request and response bodies usingawait request.aread()andawait response.aread().BodyInspectionHandler_sendwith attribute"com.microsoft.kiota.handler.body_inspection.enable".request.options.KiotaClientFactory:BodyInspectionHandlerin the default middleware pipeline followingHeadersInspectionHandler.test_body_inspection_handler.pycovering default options, custom options, rewound stream generation, request/response capture, streaming generators, empty payloads, disabled inspection, per-request overrides, and state reset.test_kiota_client_factory.pyto verify pipeline registration and options handling.Verification
packages/http/httpx: 123 passing tests (including all 13 new body inspection tests).mypy): 0 issues across all 26 source files.isortandyapf.