tower-http icon indicating copy to clipboard operation
tower-http copied to clipboard

ValidateRequest: Accept header parsing is incorrect

Open davidpdrsn opened this issue 3 years ago • 8 comments

Turns out parsing the Accept header isn't just a matter of splitting on commas, like we do here.

See https://github.com/http-rs/http-types/issues/349 for more details.

davidpdrsn avatar Aug 23 '22 07:08 davidpdrsn

@82marbag do you wanna look into this?

davidpdrsn avatar Aug 23 '22 07:08 davidpdrsn

I asked nicely and now this library has a parser for this you can use: https://github.com/picoHz/mediatype/issues/4 https://docs.rs/mediatype/latest/mediatype/struct.MediaTypeList.html

glasser avatar Aug 26 '22 05:08 glasser

@davidpdrsn should I add that as a dependency? Are you ok with it?

82marbag avatar Aug 26 '22 12:08 82marbag

That crate seems similar to mime which I believe tower-http already uses already.

davidpdrsn avatar Aug 26 '22 12:08 davidpdrsn

Yes, we're using mime. Do you prefer to move to that new crate or should I have both, the last crate for this specific issue and gradually move away from mime?

82marbag avatar Aug 26 '22 13:08 82marbag

If we can use mime then I think we should do that.

davidpdrsn avatar Aug 26 '22 13:08 davidpdrsn

I would not re-implement that in tower-http, I'd either

  • ask to implement or implement it myself in mime
  • use the mediatype crate

To implement it here maybe nom or manually. Do you have any other suggestion or which of these should I go for?

82marbag avatar Sep 01 '22 18:09 82marbag

I think the previous reply was already an endorsement of

ask to implement or implement it myself in mime

and I agree.

jplatte avatar Sep 21 '22 15:09 jplatte