Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can it be used with MultipartRequest? #95

Closed
riskiadi opened this issue Oct 27, 2021 · 18 comments
Closed

Can it be used with MultipartRequest? #95

riskiadi opened this issue Oct 27, 2021 · 18 comments
Assignees
Labels
question Further information is requested

Comments

@riskiadi
Copy link

How did you use multipart request using interceptor, i cant using interceptor with MultipartRequest() ?

final http = InterceptedHttp.build(interceptors: [Interceptor(),]);
var request = http.MultipartRequest("POST", uri);

The method 'MultipartRequest' isn't defined for the type 'InterceptedHttp'. (Documentation)

@riskiadi riskiadi added the question Further information is requested label Oct 27, 2021
@CodingAleCR
Copy link
Owner

CodingAleCR commented Oct 27, 2021

Hi, this is not yet supported in the library. However, there's an open PR so hopefully it's coming soon.

#98

@CodingAleCR
Copy link
Owner

Hey, we have a beta version that supports MultipartRequests, let me know if you are willing to try it out, it has a new API so you might need to adjust a few things (check out the guide for more info)

@riskiadi
Copy link
Author

Hi, this is not yet supported in the library. However, there's an open PR so hopefully it's coming soon.

#98

Yep, I'm so excited, thanks for developing "HTTP interceptor", I will try it later.

@CodingAleCR CodingAleCR pinned this issue Nov 25, 2021
@CodingAleCR CodingAleCR changed the title can using MultipartRequest Can it be used with MultipartRequest? Nov 25, 2021
@dexcell
Copy link

dexcell commented Nov 26, 2021

Hi, i'm trying the http interceptor for multi part seems still not working.
somehow request fields always empty when intercepting.
also retry policy is ignored.

@override
  Future<http.BaseRequest> interceptRequest({required http.BaseRequest request}) async {
    final Map<String, String>? headers = Map.from(request.headers);

    if (request is http.MultipartRequest) {
      print(request.fields); // This will show empty, even though it is populated beforehand.
    }

    return request.copyWith(
      headers: headers,
    );
  }

@CodingAleCR
Copy link
Owner

I will take a look at it closely and fix it for 2.0.0-beta.3.

Thank you for trying out the library and specially for trying out the beta version 🎊

@dexcell
Copy link

dexcell commented Nov 26, 2021

I sent pr to fix the problem, tested in my project. working well now.

@CodingAleCR
Copy link
Owner

I sent pr to fix the problem, tested in my project. working well now.

Thank you! I will Review it during the weekend and if all looks good then create a new prerelease

@jsanz1209
Copy link

Hi @CodingAleCR, I need this functionality in my project, please, when will you accept this pull request?

Thanks in advance.

@CodingAleCR
Copy link
Owner

Hi @CodingAleCR, I need this functionality in my project, please, when will you accept this pull request?

Thanks in advance.

Hey, @jsanz1209, the PR should be accepted and a new version before the weekend. Sorry for the delay! Happy Holidays!

@jsanz1209
Copy link

Hi @CodingAleCR,

Thanks for your support.

Is this hasn't been uploaded to pub.dev yet, right?

Greetings!

@CodingAleCR
Copy link
Owner

CodingAleCR commented Jan 25, 2022

Hey @jsanz1209,

I completely missed the beta.3 version release, I'm really sorry.

It should be fixed now in a new 2.0.0-beta.4 version. Feel free to try it out, any feedback is always appreciated.

@fnicastri
Copy link

Using the beta.4 and trying to implement retry policy + jwt access token on a MultiPart request.
Now facing Can't finalize a finalized MultipartRequest 'cause after the first try the files are already finalized.
Any suggestion on how to fix this?

Thanks!

@CodingAleCR
Copy link
Owner

Using the beta.4 and trying to implement retry policy + jwt access token on a MultiPart request. Now facing Can't finalize a finalized MultipartRequest 'cause after the first try the files are already finalized. Any suggestion on how to fix this?

Thanks!

That seems like an issue on the library itself, at least it has been on the past. I'll take a look and get back to you as soon as I can

@fnicastri
Copy link

Using the beta.4 and trying to implement retry policy + jwt access token on a MultiPart request. Now facing Can't finalize a finalized MultipartRequest 'cause after the first try the files are already finalized. Any suggestion on how to fix this?
Thanks!

That seems like an issue on the library itself, at least it has been on the past. I'll take a look and get back to you as soon as I can

Thanks!

@CodingAleCR
Copy link
Owner

CodingAleCR commented Mar 9, 2022

Hi just an update, the library does have issues on this front. It seems we need to copy all MultipartFiles. Otherwise the upload retry won't work because each MultipartFile is a stream and has already been closed when the MultipartRequest is closed (for example when the request fails).

Now this type of issues should only be appearing on "retried" requests. If everything is fine and the request does not need retrying then the library should work as expected ;]

@fnicastri
Copy link

yep, of course we should find a way to make it work on retried calls too.
For now I'm not using it with multipart, but I'm managing them externally.

thanks

@stale stale bot added the wontfix This will not be worked on label Jun 11, 2022
@stale stale bot closed this as completed Jun 18, 2022
Repository owner deleted a comment from stale bot Jun 18, 2022
@CodingAleCR CodingAleCR removed the wontfix This will not be worked on label Jun 18, 2022
@justincbeck
Copy link

I wish I could still set the retry policy independent of the constructor.

@CodingAleCR
Copy link
Owner

I wish I could still set the retry policy independent of the constructor.

Like having a global retry policy?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants