CodingAleCR / http_interceptor

A lightweight, simple plugin that allows you to intercept request and response objects and modify them if desired.
MIT License
133 stars 66 forks source link

Using interceptors on multipart request #123

Open abdulkash opened 1 year ago

abdulkash commented 1 year ago

When i use a logging interceptor on a multipart request it returns StreamedResponse and if i listen to this object i get "Bad state exception stream has already been listened to"

mittal-sahab-sudo commented 1 year ago

Any fix for this ? I am getting the same issue.

CodingAleCR commented 1 year ago

Hi, I'm looking into it, however I do this on my spare time, which is definitely not enough. Pull requests are always welcomed though. 😄

CodingAleCR commented 1 year ago

At the moment, the way that you can work with Multipart Requests would be to do something like in the example project. In there, you'll find a way to do requests without necessarily needing to listen to the stream.

I'm still looking for a way to "clone" the stream and data into a new one without having the stream either closed or listened to but it might take me a while to figure out a scalable solution.

abdulkash commented 1 year ago

Its the same implementation on the example code that I used but it still has the same issue

CodingAleCR commented 1 year ago

What I meant with the example is that you might not need to listen to the stream, or is there any specific reason that you want need to do that?

abdulkash commented 1 year ago

When I don't listen to the stream the logged response is StreamedResponse object

CodingAleCR commented 12 months ago

Yes, you could work with the StreamedResponse like in the Multipart Request example. You would parse the StreamedResponse to a Response and do what you need with it.

CodingAleCR commented 12 months ago

At least if you don't depend on listen. If you do then I would ask for a bit more patience since I can't look at it at the moment. Sorry it takes too long to get things done!

stale[bot] commented 9 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

eldarkk commented 2 weeks ago

Any progress with fixing issue ?