定制 componenta/http-emitter 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

componenta/http-emitter

Composer 安装命令:

composer require componenta/http-emitter

包简介

PSR-7 response emitter for Componenta

README 文档

README

PSR-7 response emitter for Componenta HTTP applications. It sends status, headers, and body content to PHP output.

Use this package at the outer HTTP entry point after the PSR-15 pipeline has produced a ResponseInterface.

Boundary

This package only emits an already built response. It does not build responses, create server requests, or run middleware. Use componenta/http-responder for response creation and componenta/app-http for the HTTP runtime pipeline.

Installation

composer require componenta/http-emitter

Componenta\Http\EmitterConfigProvider is exposed through Composer metadata.

Public API

EmitterInterface::emit(ResponseInterface $response): void emits a response. Emitter is the default implementation.

use Componenta\Http\EmitterInterface;

/** @var EmitterInterface $emitter */
$emitter->emit($response);

Emitter accepts an optional chunk size:

$emitter = new Componenta\Http\Emitter(chunkSize: 16_384);

EmitStrategy controls body emission:

Case Meaning
Full Emit the full response body.
Partial Emit a range response body.
NoBody Emit headers without a body.

EmitterException is thrown for emitter-level failures.

Runtime Behavior

Before emitting, Emitter checks that headers have not already been sent and clears active output buffers. Then it chooses a strategy from the response status and headers:

Strategy When it is used
NoBody Informational statuses, 204, 304, 416, or unsatisfiable Content-Range.
Partial Status 206 with a Content-Range header.
Full All other responses.

For full responses, the emitter adds Content-Length when the stream size is known and the header is missing. For seekable streams with known size it also adds Accept-Ranges: bytes. Bodies are streamed in chunks and stop early if the client disconnects.

For partial responses, a valid Content-Range controls the emitted byte range when the body stream is seekable. If the range cannot be parsed or the stream is not seekable, the emitter falls back to emitting the full body that is present in the response.

Configuration

The config provider registers Emitter and aliases EmitterInterface to it. Applications normally receive the emitter from the container.

Related Packages

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-06-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固