# PSR-7 Message Implementation
This repository contains a full [PSR-7](https://www.php-fig.org/psr/psr-7/)
message implementation, several stream decorators, and some helpful
functionality like query string parsing.
![CI](https://github.com/guzzle/psr7/workflows/CI/badge.svg)
![Static analysis](https://github.com/guzzle/psr7/workflows/Static%20analysis/badge.svg)
## Features
This package comes with a number of stream implementations and stream
decorators.
## Installation
```shell
composer require guzzlehttp/psr7
```
## Version Guidance
| Version | Status | PHP Version |
|---------|---------------------|--------------|
| 1.x | Security fixes only | >=5.4,<8.1 |
| 2.x | Latest | >=7.2.5,<8.4 |
## AppendStream
`GuzzleHttp\Psr7\AppendStream`
Reads from multiple streams, one after the other.
```php
use GuzzleHttp\Psr7;
$a = Psr7\Utils::streamFor('abc, ');
$b = Psr7\Utils::streamFor('123.');
$composed = new Psr7\AppendStream([$a, $b]);
$composed->addStream(Psr7\Utils::streamFor(' Above all listen to me'));
echo $composed; // abc, 123. Above all listen to me.
```
## BufferStream
`GuzzleHttp\Psr7\BufferStream`
Provides a buffer stream that can be written to fill a buffer, and read
from to remove bytes from the buffer.
This stream returns a "hwm" metadata value that tells upstream consumers
what the configured high water mark of the stream is, or the maximum
preferred size of the buffer.
```php
use GuzzleHttp\Psr7;
// When more than 1024 bytes are in the buffer, it will begin returning
// false to writes. This is an indication that writers should slow down.
$buffer = new Psr7\BufferStream(1024);
```
## CachingStream
The CachingStream is used to allow seeking over previously read bytes on
non-seekable streams. This can be useful when transferring a non-seekable
entity body fails due to needing to rewind the stream (for example, resulting
from a redirect). Data that is read from the remote stream will be buffered in
a PHP temp stream so that previously read bytes are cached first in memory,
then on disk.
```php
use GuzzleHttp\Psr7;
$original = Psr7\Utils::streamFor(fopen('http://www.google.com', 'r'));
$stream = new Psr7\CachingStream($original);
$stream->read(1024);
echo $stream->tell();
// 1024
$stream->seek(0);
echo $stream->tell();
// 0
```
## DroppingStream
`GuzzleHttp\Psr7\DroppingStream`
Stream decorator that begins dropping data once the size of the underlying
stream becomes too full.
```php
use GuzzleHttp\Psr7;
// Create an empty stream
$stream = Psr7\Utils::streamFor();
// Start dropping data when the stream has more than 10 bytes
$dropping = new Psr7\DroppingStream($stream, 10);
$dropping->write('01234567890123456789');
echo $stream; // 0123456789
```
## FnStream
`GuzzleHttp\Psr7\FnStream`
Compose stream implementations based on a hash of functions.
Allows for easy testing and extension of a provided stream without needing
to create a concrete class for a simple extension point.
```php
use GuzzleHttp\Psr7;
$stream = Psr7\Utils::streamFor('hi');
$fnStream = Psr7\FnStream::decorate($stream, [
'rewind' => function () use ($stream) {
echo 'About to rewind - ';
$stream->rewind();
echo 'rewound!';
}
]);
$fnStream->rewind();
// Outputs: About to rewind - rewound!
```
## InflateStream
`GuzzleHttp\Psr7\InflateStream`
Uses PHP's zlib.inflate filter to inflate zlib (HTTP deflate, RFC1950) or gzipped (RFC1952) content.
This stream decorator converts the provided stream to a PHP stream resource,
then appends the zlib.inflate filter. The stream is then converted back
to a Guzzle stream resource to be used as a Guzzle stream.
## LazyOpenStream
`GuzzleHttp\Psr7\LazyOpenStream`
Lazily reads or writes to a file that is opened only after an IO operation
take place on the stream.
```php
use GuzzleHttp\Psr7;
$stream = new Psr7\LazyOpenStream('/path/to/file', 'r');
// The file has not yet been opened...
echo $stream->read(10);
// The file is opened and read from only when needed.
```
## LimitStream
`GuzzleHttp\Psr7\LimitStream`
LimitStream can be used to read a subset or slice of an existing stream object.
This can be useful for breaking a large file into smaller pieces to be sent in
chunks (e.g. Amazon S3's multipart upload API).
```php
use GuzzleHttp\Psr7;
$original = Psr7\Utils::streamFor(fopen('/tmp/test.txt', 'r+'));
echo $original->getSize();
// >>> 1048576
// Limit the size of the body to 1024 bytes and start reading from byte 2048
$stream = new Psr7\LimitStream($original, 1024, 2048);
echo $stream->getSize();
// >>> 1024
echo $stream->tell();
// >>> 0
```
## MultipartStream
`GuzzleHttp\Psr7\MultipartStream`
Stream that when read returns bytes for a streaming multipart or
multipart/form-data stream.
## NoSeekStream
`GuzzleHttp\Psr7\NoSeekStream`
NoSeekStream wraps a stream and does not allow seeking.
```php
use GuzzleHttp\Psr7;
$original = Psr7\Utils::streamFor('foo');
$noSeek = new Psr7\NoSeekStream($original);
echo $noSeek->read(3);
// foo
var_export($noSeek->isSeekable());
// false
$noSeek->seek(0);
var_export($noSeek->read(3));
// NULL
```
## PumpStream
`GuzzleHttp\Psr7\PumpStream`
Provides a read only stream that pumps data from a PHP callable.
When invoking the provided callable, the PumpStream will pass the amount of
data requested to read to the callable. The callable can choose to ignore
this value and return fewer or more bytes than requested. Any extra data
returned by the provided callable is buffered internally until drained using
the read() function of the PumpStream. The provided callable MUST return
false when there is no more data to read.
## Implementing stream decorators
Creating a stream decorator is very easy thanks to the
`GuzzleHttp\Psr7\StreamDecoratorTrait`. This trait provides methods that
implement `Psr\Http\Message\StreamInterface` by proxying to an underlying
stream. Just `use` the `StreamDecoratorTrait` and implement your custom
methods.
For example, let's say we wanted to call a specific function each time the last
byte is read from a stream. This could be implemented by overriding the
`read()` method.
```php
use Psr\Http\Message\StreamInterface;
use GuzzleHttp\Psr7\StreamDecoratorTrait;
class EofCallbackStream implements StreamInterface
{
use StreamDecoratorTrait;
private $callback;
private $stream;
public function __construct(StreamInterface $stream, callable $cb)
{
$this->stream = $stream;
$this->callback = $cb;
}
public function read($length)
{
$result = $this->stream->read($length);
// Invoke the callback when EOF is hit.
if ($this->eof()) {
call_user_func($this->callback);
}
return $result;
}
}
```
This decorator could be added to any existing stream and used like so:
```php
use GuzzleHttp\Psr7;
$original = Psr7\Utils::streamFor('foo');
$eofStream = new EofCallbackStream($original, function () {
echo 'EOF!';
});
$eofStream->read(2);
$eofStream->read(1);
// echoes "EOF!"
$eofStream->seek(0);
$eofStream->read(3);
// echoes "EOF!"
```
## PHP StreamWrapper
You can use the `GuzzleHttp\Psr7\StreamWrapper` class if you need to use a
PSR-7 stream as a PHP stream resource.
Use the `GuzzleHttp\Psr7\StreamWrapper::getResource()` method to create a PHP
stream from a PSR-7 stream.
```php
use GuzzleHttp\Psr7\StreamWrapper;
$stream = GuzzleHttp\Psr7\Utils::streamFor('hello!');
$resource = StreamWrapper::getResource($stream);
echo fread($resource, 6); // outputs hello!
```
# Static API
There are various static methods available under the `GuzzleHttp\Psr7` namespace.
## `GuzzleHttp\Psr7\Message::toString`
`public static function toString(MessageInterface $message): string`
Returns the string representation of an HTTP message.
```php
$request = new GuzzleHttp\Psr7\Request('GET', 'http://example.com');
echo GuzzleHttp\Psr7\Message::toString($request);
```
##
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
陀螺匠v1.4新增功能 一、客户管理 1、客户公海:对于没有业务员的客户,支持进行领取、分配、设置标签、标为流失等操作。 2、自定义字段:支持添加客户、合同、联系人的自定义字段设置。 3、审批流程:付款、支出、发票支持自定义审批流程,对应增加控件组;若审批通过允许撤销,审批通过发起人进行撤销之后,财务相关账目数据进行删除。 4、规格配置:支持进行跟进规则、退回公海规则、审批规则的配置。 5、全电发票对接 对接一号通电子发票功能,支持在系统中开具电子发票 (1)合并开票:一张发票关联不同合同的付款记录,关联的每个合同均能看到此发票记录。 (2)收支记账中,优化展示客户名称、合同名称,方便对账。 二、绩效考核优化 1、人事-考核记录中,优化展示本月的未创建考核人员。 2、绩效考核,上级进行两次评分后,未到考核结束时间,状态不切换为【已结束】。 3、重新梳理优化绩效的权限与按钮判断,以及查看页面的操作控制。 4、考核指标库的相关优化 (1)排序按照创建时间倒叙排序 (2)增加搜索,支持按照模板名称及简介进行筛选。 (3)默认选中第一个模板 原版源码,未做任何修改处理,仅供研究学习,授权
资源推荐
资源详情
资源评论
收起资源包目录
CRMEB陀螺匠·企业助手OAv1.4公测版发布 (2000个子文件)
my.cnf 1KB
redis.conf 20KB
app.f712284a.css 766KB
element.css 233KB
bootstrap.min.css 158KB
bootstrap.min.css 100KB
chunk-libs.0afaa212.css 88KB
index-95a13e83.css 57KB
ignition.css 49KB
editor-c4e5ff15.css 41KB
uni-row-551256e4.css 40KB
uni.78ceb9d5.css 36KB
iconfont.css 24KB
index-9f84a56d.css 23KB
statistics-c6412048.css 22KB
font-awesome.min.css 17KB
detail-155c56e1.css 15KB
exception.css 14KB
iconfont.css 12KB
index-dab46144.css 12KB
details-c4ff5331.css 11KB
details-2f74f175.css 11KB
uni-datetime-picker-68911624.css 11KB
statistics-0d3f6241.css 10KB
index-5132aa21.css 10KB
index-2fb6ee0b.css 10KB
defaults-cf5b4c5f.css 10KB
whoops.base.css 10KB
index-1083fa2d.css 10KB
uni-icons-4783ceaf.css 10KB
nv.d3.min.css 9KB
mine-b9e45c11.css 9KB
census-2e40f4ad.css 8KB
default-0ceffa3a.css 6KB
paymentExamine-1d104fb2.css 6KB
chunk-7529257f.b09317b0.css 6KB
index-221fb224.css 5KB
default-6006cb31.css 5KB
index-3ad292c4.css 5KB
invoiceExamine-3e9772f9.css 5KB
addSpend-03e08ebb.css 5KB
create-f9f53061.css 5KB
uni-data-picker-b59cad42.css 5KB
default.css 5KB
contractList-c636a2c7.css 5KB
forumList-a55938eb.css 4KB
personalReport-373f4089.css 4KB
paymentRecord-b83422e4.css 4KB
folderList-43ea9516.css 4KB
invoiceDetail-d96958ad.css 4KB
invoiceList-a84ef253.css 4KB
info-361fa5b8.css 4KB
addPayment-f0fde814.css 4KB
index-7ba9dfe3.css 4KB
chunk-3b2c3198.d1dba4df.css 4KB
manage-b550558b.css 4KB
addFollow-6c62f75e.css 3KB
index-d2fd13ae.css 3KB
rules-982ec3b1.css 3KB
work-6f3ddac2.css 3KB
prism.css 3KB
personal-892e985b.css 3KB
selectedLabel-beb5ee56.css 3KB
selectedLabel-e624388a.css 3KB
addRemind-bd14d66a.css 3KB
addInvoice-ac76e8a0.css 3KB
teamCheckList-0d1806a7.css 3KB
htmlDescriptor.css 3KB
uni-list-a119584f.css 3KB
selectBottomBar-43316795.css 3KB
teamReport-b72618e3.css 3KB
exception_full.css 3KB
addCustomer-a6bb0835.css 3KB
addFile-1c9df0a8.css 3KB
index-d784535b.css 3KB
addContract-2005feb5.css 3KB
userOvertimeList-e5021474.css 3KB
style.css 3KB
chunk-c871c564.55a2bad3.css 2KB
file-30d333af.css 2KB
phone-9f1fd2f3.css 2KB
password-262c67f5.css 2KB
userVacationList-85813a3a.css 2KB
addLiaison-899ae4e8.css 2KB
examineTab-9abdee9f.css 2KB
liaison-4a735115.css 2KB
shift-461de511.css 2KB
userCheckList-26dd381f.css 2KB
userId-9905456d.css 2KB
customerListDefault-fea5d7d7.css 2KB
default-a11fe8d8.css 2KB
index-e405d1da.css 2KB
index-5e2e5df5.css 2KB
userPhone-935f050b.css 2KB
mp-html-f0149230.css 2KB
index.css 2KB
index-b9098cbc.css 2KB
index-ed235b49.css 2KB
checkPayment-4a3c2308.css 2KB
xp-picker-4edaae7a.css 2KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
姐法眼一睁就知道你是妖孽
- 粉丝: 1
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于二阶自抗扰ADRC的轨迹跟踪控制,对车辆的不确定性和外界干扰具有一定抗干扰性,基于carsim和simulink仿真 跟踪轨迹为双移线,效果良好,有对应复现资料,是学习自抗扰技术快速入门很好的资料
- 基于python的网页自动化工具项目全套技术资料100%好用.zip
- MATLAB【逆变器二次调频模型】 微电网分布式电源逆变器DROOP控制二次调频模型,加入二次控制实现二次调频控制,及二次调压控制,程序可实现上图功能,工况有所改变 需要matlab2021A版
- 抢购软件:快速复制信息
- 单机无穷大系统发生各类(三相短路,单相接地,两相接地,两相相间短路)等短路故障,各类(单相断线,两相断线,三相断线)等断线故障,暂态稳定仿真分析
- 微信文章爬虫项目全套技术资料100%好用.zip
- 基于动态窗口算法的AGV仿真避障 可设置起点目标点,设置地图,设置移动障碍物起始点目标点,未知静态障碍物 动态窗口方法(DynamicWindowApproach) 是一种可以实现实时避障的局部规划算
- Power Quality Disturbance:基于MATLAB Simulink的各种电能质量扰动仿真模型,包括配电线路故障、感应电机启动、变压器励磁、单相 三相非线性负载等模型,可用于模拟各种
- 数据爬虫项目全套技术资料100%好用.zip
- 聊天系统项目全套技术资料100%好用.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功