TestResponse has no way to read the raw response body

Open
#849 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@rafamolina1 is already working on this.

Since Dec 4, 2026.

  • #878 by @rafamolina1 — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
25/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Stale
Tech stack
rust
Domain
testing

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from laravel/rust-framework

All issues in laravel/rust-framework

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.