TestResponse has no way to read the raw response body
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 25/100
Research direction
The issue points to laravel-rust-0.2.0/src/testing/response.rs and says the response body is already held as Bytes. Start by reading TestResponse and its existing body accessors, then check the related tests. Done means tests can retrieve the original response bytes; an open pull request (#878) is already linked to this issue.
Written by the indexing model from the issue text.
Description
TestResponse exposes the body as text() (lossy UTF-8) and json(). There's no accessor for the raw bytes, so a test can't decode a binary response, for example to check an image's dimensions, a PDF's header, or a download's exact bytes. Lossy UTF-8 replaces invalid sequences, so text().as_bytes() isn't the original body.
let response = app.get("/avatar.png").await;
response.assert_ok().assert_header("content-type", "image/png");
let bytes = response.text().into_bytes(); // not the PNG that was sent
Suggestion
Add TestResponse::bytes(&self) -> &[u8] (the body is already held as Bytes), and perhaps assert_body(expected: &[u8]).
Seen on 0.2.0 (laravel-rust-0.2.0/src/testing/response.rs); the same on 0.x at 6156f0e.
- Dominant language
- Rust
- Stars
- 847
- Forks
- 174
- Avg merge
- 5h 40m
- Merged PRs (30d)
- 167
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from laravel/rust-framework
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
laravel/rust-framework#864 ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 64/100
laravel/rust-framework#876 ·
Maintainers usually reply within 1 day
-
Case-sensitive contains, starts_with and ends_with that match % and _ literally on every databaseOpen
Difficulty 4/5 3-5 days Newbie friendliness 58/100
laravel/rust-framework#874 ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
laravel/rust-framework#873 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 58/100
laravel/rust-framework#872 ·
Maintainers usually reply within 1 day
All issues in laravel/rust-framework
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
neuralmagic/crucible#579 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
eclipse-score/kyron#249 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
seanmonstar/reqwest#3157 ·
Maintainers usually reply within 2 days