alexliesenfeld / httpmock

HTTP mocking library for Rust.
MIT License
435 stars 40 forks source link

Question about type correctness and the http crate #89

Open Ducky2048 opened 10 months ago

Ducky2048 commented 10 months ago

I just started using httpmock. One thing I immediately noticed is how it doesn't seem to be using the types I'd consider most appropriate.

The http crate defines commonly needed http related types which are used by a lot of well-known libraries in the ecosystem like tower, hyper and reqwest.

To my surprise, this crate doesn't. For example, it redefines the http Method enum instead of using the types from the http crate "everyone else" in the ecosystem uses. I think it would be better to use the common types.

Something else I noticed: When.header taking (Into<String>, Into<String>) instead of the (in my opinion) properly typed (Into<http::HeaderName>, Into<http::HeaderValue>). (Not every String is a valid http header, which is why in my opinion this type is not quite correct.)

Also, when.Body takes an Into<String>, but http can transport many things in its body, including binary data. This is accounted for in Then as it takes an impl AsRef<[u8]> but not in When, preventing (as far as I can tell) matching on non-string request bodies.

Are these intentional design choices? If not, would you consider pull requests adressing this?

github-actions[bot] commented 9 months ago

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] commented 8 months ago

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] commented 7 months ago

This issue was closed because it has been inactive for 14 days since being marked as stale.