http-rs / http-rs/http-types

`Accept::negotiate` does not handle wildcards correctly

Open
#402 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Rust
Stars
209
Forks
91
PR merge metrics
No merged PRs in 30d

Description

It correctly handles `*` but not `*/*` and `basetype/*`. For example, the spec indicates that `*/*` should accept any media type, but the following snippet fails with `No suitable Content-Type found`
```rust
let mut req = Request::new(Method::Get, "http://localhost");
req.append_header("Accept", "*/*");
let mut accept = Accept::from_headers(&req).unwrap().unwrap();
accept.negotiate(&[mime::JSON]).unwrap();
```

Likewise, this also fails:
```rust
let mut req = Request::new(Method::Get, "http://localhost");
req.append_header("Accept", "application/*");
let mut accept = Accept::from_headers(&req).unwrap().unwrap();
accept.negotiate(&[mime::JSON]).unwrap();
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.