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't set custom Content-Type #9

Closed
virmundi opened this issue May 4, 2018 · 6 comments
Closed

Can't set custom Content-Type #9

virmundi opened this issue May 4, 2018 · 6 comments
Labels
enhancement New feature or request

Comments

@virmundi
Copy link
Contributor

virmundi commented May 4, 2018

I use custom mimetypes for all of my calls. When attempting to post, the header value I put in gets overridden by the body configuration. I've not been able to undo that override.

@RohitAwate
Copy link
Owner

I see. Yes, Everest determines the content type from the body.
I'll add a mechanism by which the content type from the headers (if any) overrides the one determined from the body. This will probably take a couple of weeks though. I have my finals coming up and I'm also working on the core-optimization branch. Sound good?

@RohitAwate RohitAwate added the enhancement New feature or request label May 4, 2018
@virmundi
Copy link
Contributor Author

virmundi commented May 5, 2018

Sure. While you do your thing, I'll look into your code. Maybe I can make a pull request.

@RohitAwate
Copy link
Owner

Hi,

I've been evaluating this issue and have a few questions. To be frank, I've never used custom types so I tried them on Insomnia and noticed that it allows overriding for all types of request bodies except multipart/form-data. Do you happen to know why they're doing so?

I have a solution almost ready. Feel free to contribute though. I'll be putting up a Contributions Guide soon so I suggest you wait for that before making a PR.

@virmundi
Copy link
Contributor Author

virmundi commented May 6, 2018

I'll take your pull. I noticed you use the content type to drive a lot of internal logic like BodyTagController's switch around line 142 and other places. I'm not sure how I'd refactor that kind of code without moving a lot of parts. I was trying to see how to not use DashboardState.getContentType(), but rather the headers.

I'm not familiar with Insomnia, but I use Postman. Basically, multipart/form is an official encoding spec. Everything else is just characters as far as HTTP is concerned. People just like to use json since it's less verbose than XML, and readable. Nothing stops anyone from dropping Java serialized messages into a post body and setting the correct Content-Type header.

As part of REST, one should define their own schema/MimeTypes. That's part of the whole HATOEAS thing. Often people skip this and just use application/json. Unfortunately, that's not enough contextual info for a rest client. That's why I use the Mime Type. All of mine are serialized as JSON, but for correctness and debugging my services all define the resource with Mime Types. Hope this doesn't come across as preachy, just trying to share why people use this technique.

@RohitAwate
Copy link
Owner

Not preachy at all, that's really helpful. Thanks a lot! 👍

I've made changes to DataDispatchRequestManager, which handles POST, PUT and PATCH requests. Basically, it will still determine the content type from the UI (based on the tab you have selected), but it will now check for an override before making the request.

I request you to try out this this test build and let me know if this works for you. If you have any issues, we'll sort them out else I'll push the changes to the core-optimization branch. I have a few more things in mind before I push out Alpha 1.1 so I suggest you build from core-optimization meanwhile.

@virmundi
Copy link
Contributor Author

That worked great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants