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

Add support for MultipartBody.Part in @Part #1467

Closed
wants to merge 1 commit into from
Closed

Add support for MultipartBody.Part in @Part #1467

wants to merge 1 commit into from

Conversation

JayNewstrom
Copy link
Contributor

This is very much a work in progress. But it works for my needs. I'd like to push this functionality forward, but could use some direction. I'm happy to update the PR given any direction, or let someone else take over.

References #1140

@JayNewstrom
Copy link
Contributor Author

There are a couple of interesting things I ran into with this change

  • The value of @Path will be ignored if you pass in MultipartBody.Part
  • There is no request body ConverterFactory for MultipartBody.Part so it blows up without the changes in RequestAction
  • I think the changes are needed in RequestAction.Part for the iterable and array versions, however, I didn't test that.
  • I also introduced an unchecked cast on RequestFactoryParser line 437

body = converter.convert(value);
} catch (IOException e) {
throw new RuntimeException("Unable to convert " + value + " to RequestBody", e);
if (MultipartBody.Part.class.isAssignableFrom(value.getClass())) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is known in the RequestFactoryParser and should have an action chosen for the type, not as just-in-time behavior.

@JakeWharton
Copy link
Collaborator

There are many edge cases around this which are unknown and need evaluated before decided how to support this.

@JayNewstrom
Copy link
Contributor Author

I've updated the pull request. I'm not sure there's a clean way to do it in RequestFactoryParser because of the iterable/array implementations. I've added another test case to cover that functionality as well.

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.

2 participants