Skip to content

Conversation

@root-aza
Copy link
Contributor

@root-aza root-aza commented Oct 12, 2025

Q A
Bugfix? ✔️
Breaks BC?
New feature?

Fixed signature HttpWorkerInterface

Summary by CodeRabbit

  • New Features
    • Added an optional flag to response handling that explicitly marks the end of streaming responses. This enables finer control over when streams terminate and supports more robust streaming scenarios. Existing behavior remains unchanged if the flag isn’t provided, ensuring backward compatibility and a seamless upgrade path for current integrations.

@coderabbitai
Copy link

coderabbitai bot commented Oct 12, 2025

Walkthrough

The HttpWorkerInterface’s respond method signature now includes an optional bool parameter endOfStream (default true), expanding from three to four parameters. This modifies the public interface and call pattern for streaming responses while preserving prior behavior when the new parameter is omitted.

Changes

Cohort / File(s) Summary
HTTP Worker interface API update
src/HttpWorkerInterface.php
Added optional bool $endOfStream = true to `respond(int $status, string

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant C as Client
    participant S as Server/App
    participant W as HttpWorkerInterface

    C->>S: HTTP Request
    S->>W: respond(status, body, headers, endOfStream)

    alt endOfStream = true
        Note right of W: Final chunk sent<br/>Connection closed
        W-->>C: Send body and terminate stream
    else endOfStream = false
        Note right of W: Chunked/streaming<br/>More data expected
        W-->>C: Send body chunk, keep stream open
        S->>W: respond(..., endOfStream=true) for final chunk
        W-->>C: Send final chunk and close
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I twitch an ear at streams that flow,
A gentle flag to end—or no?
One nibble more, then close the seam,
Or keep the carrots in the stream.
With one small bool, I hop with glee—
The final byte is up to me! 🥕🐇

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title directly reflects the core change of the PR, which is updating the signature of the HttpWorkerInterface’s respond method, and concisely communicates that the interface contract was fixed.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a44a5f7 and c6484a4.

📒 Files selected for processing (1)
  • src/HttpWorkerInterface.php (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/HttpWorkerInterface.php (2)
src/PSR7Worker.php (1)
  • respond (87-96)
src/HttpWorker.php (1)
  • respond (87-100)
🔇 Additional comments (1)
src/HttpWorkerInterface.php (1)

32-32: All respond implementations conform to the updated interface. HttpWorker’s signature now includes the new endOfStream parameter, and PSR7Worker passes status, body and headers—relying on the default endOfStream value.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a44a5f7 and 53d020b.

📒 Files selected for processing (1)
  • src/HttpWorkerInterface.php (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/HttpWorkerInterface.php (2)
src/PSR7Worker.php (1)
  • respond (88-97)
src/HttpWorker.php (1)
  • respond (86-99)
🔇 Additional comments (1)
src/HttpWorkerInterface.php (1)

33-33: Verified: all HttpWorkerInterface implementations include the $endOfStream parameter and match the updated signature.

* that header.
*/
public function respond(int $status, string|\Generator $body, array $headers = []): void;
public function respond(int $status, string|Generator $body, array $headers = [], bool $endOfStream = true): void;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Fix formatting and update the docblock.

Two issues to address:

  1. There's a double space before bool $endOfStream
  2. The docblock (lines 21-32) doesn't document the new $endOfStream parameter

Apply this diff to fix the formatting:

-    public function respond(int $status, string|Generator $body, array $headers = [],  bool $endOfStream = true): void;
+    public function respond(int $status, string|Generator $body, array $headers = [], bool $endOfStream = true): void;

And update the docblock to include:

      * @param HeadersList|array<array-key, array<array-key, string>> $headers $headers An associative array of the
      *        message's headers. Each key MUST be a header name, and each value MUST be an array of strings for
      *        that header.
+     * @param bool $endOfStream Whether this response marks the end of the stream. Default is true.
      */
     public function respond(int $status, string|Generator $body, array $headers = [], bool $endOfStream = true): void;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
public function respond(int $status, string|Generator $body, array $headers = [], bool $endOfStream = true): void;
* @param HeadersList|array<array-key, array<array-key, string>> $headers $headers An associative array of the
* message's headers. Each key MUST be a header name, and each value MUST be an array of strings for
* @param bool $endOfStream Whether this response marks the end of the stream. Default is true.
*/
public function respond(int $status, string|Generator $body, array $headers = [], bool $endOfStream = true): void;
🤖 Prompt for AI Agents
In src/HttpWorkerInterface.php around line 33, the method signature currently
has an extra double space before "bool $endOfStream" and the docblock above
(lines ~21-32) does not document the new $endOfStream parameter; remove the
extra space so the signature reads with a single space before the type, and
update the docblock to include a @param bool $endOfStream description (e.g.,
whether this response is the final stream chunk) and any default behavior,
keeping formatting consistent with existing @param entries.

Copy link
Member

@roxblnfk roxblnfk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't add parameters into interface in minor version. It's breaking change because the interface isn't marked as internal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants