Rocket icon indicating copy to clipboard operation
Rocket copied to clipboard

Do not warn about unknown mime types

Open RomanHodulak opened this issue 4 years ago • 5 comments

In several use cases, I use non-standard mime types. In particular, I've used application/x-7z-compressed to accept a 7z archive and application/vnd.move+json to distinguish between POST route that moves a resource and another one that creates a resource.

Because of this I always get compiler warnings about non-existing mime types such as:

warning: 'application/vnd.move+json' is not a known media type

Therefore I suggest that mime types with x- and vnd. prefix should be ignored by this warning.

RomanHodulak avatar Dec 17 '19 15:12 RomanHodulak

There are other, standard media types that also warn. For example, I'm using application/merge-patch+json for my app and I'm getting these too.

sazzer avatar Mar 11 '20 18:03 sazzer

@sazzer If there's a standardized and registered media type that Rocket is unaware of, please open a PR to add it to the list of known media types.

SergioBenitez avatar May 21 '21 18:05 SergioBenitez

For posterity: there is no nice mechanism, as of yet, to request that warnings emitted from proc-macros be silenced in any fashion. Note that, on stable, we cannot emit warnings (without an error), so this issue only applies to nightly. To track upstream changes that would allow us to resolve this issue, see https://github.com/rust-lang/rust/issues/54140 and specifically my proposal at https://github.com/rust-lang/rust/issues/54140#issuecomment-802701867.

SergioBenitez avatar May 21 '21 18:05 SergioBenitez

Is there no way in rocket to add mime types via configuration. See the warning, add to configuration. From a security monitoring and blocking perspective if mime type is not allowed it shouldn't be served and should be reported.

Paul-J-Barrett avatar Oct 09 '21 17:10 Paul-J-Barrett

See https://github.com/SergioBenitez/Rocket/discussions/2503#discussioncomment-5447420 for some of my latest thoughts on this.

SergioBenitez avatar Mar 28 '23 18:03 SergioBenitez