roc-lang / roc-lang/basic-cli

Add configurable limits for HTTP response bodies

Open
#436 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement high priority
Dominant language
Rust
Stars
121
Forks
45
Avg merge
18h 43m
Merged PRs (30d)
10

Description

Context

The HTTP host collects the complete response body into memory before returning it to Roc:

  • src/http.rs:141-165
  • specifically response.into_body().collect().await at line 155

A slow response can be constrained with the existing request timeout, but there is no response-size limit. A server can therefore return a very large fixed-length or chunked body and cause excessive memory use or an allocation abort.

This matters for a general-purpose CLI platform because URLs and servers are often outside the application's control.

Suggested direction

Add an explicit maximum response-body size to the HTTP API. Design options include:

  • a limit on the shared request configuration;
  • a platform-level default plus an opt-in override;
  • a separate bounded send operation.

Enforce the limit while consuming frames, rather than collecting first and checking afterward. Return a distinct typed error that callers can distinguish from malformed bodies and network failures.

A later streaming response API can be tracked separately; this issue only needs bounded buffering.

Acceptance criteria

  • Callers can select or rely on a documented finite response-body limit.
  • Both Content-Length responses and chunked/unknown-length responses are stopped before exceeding the limit.
  • Exceeding the limit returns a documented typed error rather than panicking or aborting.
  • Tests cover a body just below the limit, exactly at it, above it, and a chunked body above it.
  • Existing normal HTTP examples continue to pass on every supported target.

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 in src/http.rs:141-165, especially response.into_body().collect().await at line 155, and inspect the existing request configuration and HTTP examples. Define how the limit is selected and how the typed error is exposed, then enforce it while consuming both fixed-length and chunked bodies. Done means the acceptance tests cover below, exact, above, and chunked limits while existing examples pass on supported targets.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli, networking
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.