# PSR-7 Message Implementation
This repository contains a full [PSR-7](http://www.php-fig.org/psr/psr-7/)
message implementation, several stream decorators, and some helpful
functionality like query string parsing.
[![Build Status](https://travis-ci.org/guzzle/psr7.svg?branch=master)](https://travis-ci.org/guzzle/psr7)
# Stream implementation
This package comes with a number of stream implementations and stream
decorators.
## AppendStream
`GuzzleHttp\Psr7\AppendStream`
Reads from multiple streams, one after the other.
```php
use GuzzleHttp\Psr7;
$a = Psr7\stream_for('abc, ');
$b = Psr7\stream_for('123.');
$composed = new Psr7\AppendStream([$a, $b]);
$composed->addStream(Psr7\stream_for(' 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\stream_for(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\stream_for();
// 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\stream_for('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 deflate or gzipped content.
This stream decorator skips the first 10 bytes of the given stream to remove
the gzip header, 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\stream_for(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\stream_for('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;
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\stream_for('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\stream_for('hello!');
$resource = StreamWrapper::getResource($stream);
echo fread($resource, 6); // outputs hello!
```
# Function API
There are various functions available under the `GuzzleHttp\Psr7` namespace.
## `function str`
`function str(MessageInterface $message)`
Returns the string representation of an HTTP message.
```php
$request = new GuzzleHttp\Psr7\Request('GET', 'http://example.com');
echo GuzzleHttp\Psr7\str($request);
```
## `function uri_for`
`function uri_for($uri)`
This function accepts a string or `Psr\Http\Message\UriInterface` and returns a
UriInterface for the given value. If the value is already a `UriInterface`, it
is returned as-is.
```php
$uri = GuzzleHttp\Psr7\uri_for('http://example.com');
assert($uri === GuzzleHttp\Psr7\uri_for($uri));
```
## `function stream_for`
`function stream_for($resource = '', array $options =
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
可以说这是目前以来很牛的一款源码,无论是流畅度,还是原生稳定性 测试环境 *APP环境:Android Studio,纯Java原生开发。 后端环境:PHP7.2+MySQL 5.6.49L+Nginx 1.18.0+sg11 账户密码:后端后台/admin.php,后台账户:admin,后台密码:admin123456 直接上传访问安装 后台地址 你的网站地址/admin.php 账号admin 密码123123 前端模板海螺的 php必须安装sg11扩展插件,php版本7.0~7.2 本人测试环境bt nginx 1.18.0、php-7.0、mysql 5.6.50 记得安装扩展 fileing、memcached、sg11 分享页面在苹果cms程序/reg/reg.html在这里修改 前端 推荐9是首页轮播图 推荐8是分类轮播图 推荐6是首页视频推荐 热播就是热播推荐 这里有完整编译app教程 属于极光颜色的版本 视频下载等 安装详情:http://ban.maonius.cn/app/158.html
资源推荐
资源详情
资源评论
收起资源包目录
[2022年]最新萝卜影视APP源码麻花金色UI最新原生版APP (7191个子文件)
+3mPr82mLqqT7EOdaLeubDf9QYc= 665KB
+3mPr82mLqqT7EOdaLeubDf9QYc= 665KB
+a6UaWPXnuNS3Nv+noxkkfRPORI= 102KB
+a6UaWPXnuNS3Nv+noxkkfRPORI= 102KB
+bcPCktatzq02sPS7Wcfhinyqf4= 29KB
+bcPCktatzq02sPS7Wcfhinyqf4= 29KB
+fhv4bFvDLDsfCf2P8QCt6qZ2Gw= 33KB
+fhv4bFvDLDsfCf2P8QCt6qZ2Gw= 33KB
+mHT0xzd+By9dh7ZO25L1xakIb8= 196KB
+mHT0xzd+By9dh7ZO25L1xakIb8= 196KB
+RMxvLUA+eI1l9L_HadaGHTVWyY= 7KB
+RMxvLUA+eI1l9L_HadaGHTVWyY= 7KB
+uwoAgEsMdwjgHpI_2d+11bXGok= 669KB
+uwoAgEsMdwjgHpI_2d+11bXGok= 669KB
00e137f5c6fda742101cf216057a8f129c35fa 547B
00ec72ff07e1d67b8bc2bf1d938c104009e0d9 3KB
0160a4a018b79d333fe38802cb1b175219cbd9 297B
019b2e9cd7c00cfb5e3f8f3f9f7b2e54fabe64 2KB
01af24622f318402255c928320cf1cf9ce7ec3 282B
02b87ff50975e13ff06feaf50a456eca7b481b 75B
0306ecdb91cd3e8323331de039d39f05437518 1KB
03e2559288a1c9e042c75df94f797b85c07959 192B
040729a809eba828f034cb16ba3e8334019319 3KB
040c5b8562908b5a64ef63af863fb1b025c2e1 810B
041efc498790b291cca32299901a8c4beea867 218B
047422e02327806655ec9f797537cffb723eef 116B
05098cb104982a05e5fcdf24ea13f77f5b5645 526B
058dd2c6bb4d23aea5c1627e8437e1e5955c1c 850B
060e48bafa603f1ed8647e0ed03d15ca6c07d0 137B
061e20246e2f0fa593027bd48c22376fdc5db1 804B
0628029c923acd97fe5b99c3270e36114b1147 676B
06548803839ed66643741390a792ba9826e485 98B
0674470f8052bb64c64a5b513f5df2815a70c1 161B
069c52490bc5d4e277c4d7280d0c625ceeea19 249B
06aa5fe9b256bc65334721e42a29f242d831fe 60B
072aac6a828d1b47e5e628fe80b4541c1c78a3 1KB
075e5225d5835b23b5445db67677b9a0f82e91 44B
07d73d97a0ecfed61ca19aadbae288b5495368 82B
0922032fbcfdedb0dcf3b018fb60466ad7d098 2KB
093abc924a656e352cf0d5b5dd4fe03b953e92 206B
0949b1a31367367bd40a6d1273cc508d9efa5f 521B
0a4f5e3cdef6b6b736681a5a20ee0d890ba981 366B
0a53014f9d16ff83fc802ed70a2b6232c82964 2KB
0ab0c8590e305b4ae355a5a23e99c60bf8637a 901B
0ae77fe96f75d96f1cab77cc49416383946556 132B
0aead8735d4b2aaf744ee216db84f1fd5fde8b 236B
0b07415e5facf76378e0e3912f18fc06416fc1 2KB
0b7a8057c1de3f767f200af3990d6ab4da300e 159B
0ba04936a72186f1e842fd58096acbab373be6 781B
0c26f19bcfca824308f3d7e5f2828a9d724181 1KB
0c3ef912f49e9415dc3ff7ce2b0484b153fd60 6KB
0c5ac3be45e8ee03dc46881e19cb2ccd26b79c 432B
0c9f78b9628cb208dcd2d370ff9cf1d1254fc1 49B
0caca1c82daa4cdc88fdb57ff754af0e7ccc3b 185B
0cae9b8521cadbcbfd8a970f973e101db62d19 2KB
0ce0c0d3a4f9c187b875c287a167352d7685a3 521B
0d1547ee38fdae80ca0d5c0f7fab13967931b6 1KB
0d1b022406280e7931f1b77a457a25c8215261 913B
0d46dd267de24c47d3806c1e37238705d15055 2KB
0d5038a100cf178a2808556f96d53b25f1f068 2KB
0d5546bbf4d4d1cf83360236251a5a2c31df69 266B
0d591f1b73ea1be46bb5ad669d8b6e3b0b701e 449B
0d86174b73a51206608cb45de7a93ba8fd507b 139B
0dde0b9e4b2f4673fe35c2b1fac4f0cd1988ca 4KB
0dfd11cdcaa8458873780ec57ed38fa5ce9ca0 2KB
0eeba59ab9534fa18d1e607d23e7d4e26d3603 44B
0f878b69df63b5f62da7a918f32c21ff745686 870B
0f901bdeda9b5836c23f642fa82249c4331d2e 174B
0fab27ad72f88027b4fda7e1f7ab8a5ebdd26d 3KB
0fdc1c847a4be72ca94743695fafcebe320e8f 158B
0JdG9L7IAGUlsAMyvinq9iQWxek= 22KB
0JdG9L7IAGUlsAMyvinq9iQWxek= 22KB
0Whdj34LZo8EzlUOaJqS3lPkxEM= 23KB
0Whdj34LZo8EzlUOaJqS3lPkxEM= 23KB
1010dbf3a94d825684c5d1bd417eb7d851e125 230B
10924650df7d2c66c68ac700ee2e76ad99a259 72B
10a096ad2e1493958d81a985fc35545d909368 1KB
1120e73c6e0a8cf06155292e63e8e91f4f61fd 2KB
114eec6ae8d5e8bd8a28991383fa186c61133e 48B
1179534065f003785d59fe231ebad10fd0098c 949KB
119cb5397879e69377193d2715b5abd3587c73 592B
11b61a4d05682f559e2dcb174642441c51063f 176B
11c8b75585cd6c430d68577803436193979dfe 270B
11fc82289bc951020bbd33add2c45f90f8b296 703B
1298f1a8b1214d0b5ca4045f53cba9285f293d 413B
12cc807145f468011866b20ec6c74f7b80ac27 243B
1319b09b938a29431a67bf7aa2509c6c75afa0 827B
1341f915ba7b6e90ae53cabbd399e59560b01d 859B
13e309b4421340ca7850e610a3b95334d6fb9a 2KB
14c089f5ac1165bf6953e98aa2c3cba4c48f79 2KB
14d0694921c4d863bcfb1b8f37595212f3f6ef 37B
14d10927c675068f82f8c88791a277df03907d 338B
15290a3e71cd7014c9a393aa6415c5671c6b0e 25KB
1550d62c5421bae32e08d8221f305760ddf483 1KB
15733b7163cacd59b77dbbb1c05cca33979cf7 608B
1587a0861773b0ad35fe5da5aecb39e93b8c1d 56B
15e6025a17add3f467454ebc7e51781e5d6817 207B
162e7255efd9af8fc1a31aa1f519578eef9207 48B
163d0f5a2ef353e13017b45a9066b72a84ca24 152B
1665b657c392eec2d5568dbbe8e9b47db6a824 64B
共 7191 条
- 1
- 2
- 3
- 4
- 5
- 6
- 72
资源评论
- Zhuzhuanyzz2022-05-11用户下载后在一定时间内未进行评价,系统默认好评。
搬运站长
- 粉丝: 13
- 资源: 57
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功