hyperium / hyperium/hyper

Feature: Implement the Body trait for more native data types to improve ergonomics

Open
#3,746 7 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

B-rfc C-feature
Dominant language
Rust
Stars
16.3k
Forks
1.8k
Avg merge
1d 22h
Merged PRs (30d)
14

Description

Currently, the 'String' is the only native data type that implements hyper::body::Body.
If we're passing other data types as a body, we need to add the http_body_util crate and add a little bit of boiler plate when building our request.

use http_body_util::Full;

let some_bytes = vec![0_u8, 1, 2];
let mut req = Request::builder()
    .method("POST")
    .body(Full::<Bytes>::from(some_bytes))
    .unwrap();

Note: While the request builder itself may not require the body to implement the Body trait, both the sender and connection returned by http1::handshake require the request's body to implement it.

With the body trait implemented for Vec<u8> (just one example that probably should implement body) we could leave out the http_body_util crate. Building a request would also become more intuitive and ergonomic.

    let some_bytes = vec![0_u8, 1, 2];
    let mut req = Request::builder()
        .method("POST")
        .body(some_bytes)
        .unwrap();

Contributor guide

Open the contributing guide

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.

Research direction

Start by reviewing the hyper::body::Body trait and the request path through http1::handshake, including the sender and connection requirements described in the issue. Confirm which native types are in scope beyond Vec<u8> and define completion around sending requests with those types without http_body_util; the issue does not name files or tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
networking
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.