Skip to content

Commit fe15f35

Browse files
committed
Merge pull request #21 from php-http/chunk_compat
Autoregister filters using Composer autoload
2 parents 78b7b7c + 185c8dc commit fe15f35

File tree

5 files changed

+17
-9
lines changed

5 files changed

+17
-9
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
# Change Log
22

33

4+
## Unreleased
5+
6+
### Added
7+
8+
- Autoregistration of stream filters using Composer autoload
9+
10+
411
## 0.1.2 - 2015-12-26
512

613
### Added

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@
3131
"autoload": {
3232
"psr-4": {
3333
"Http\\Message\\": "src/"
34-
}
34+
},
35+
"files": [
36+
"src/filters.php"
37+
]
3538
},
3639
"autoload-dev": {
3740
"psr-4": {

src/Encoding/ChunkStream.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ class ChunkStream extends FilteredStream
1414
*/
1515
public function getReadFilter()
1616
{
17-
if (!array_key_exists('chunk', stream_get_filters())) {
18-
stream_filter_register('chunk', 'Http\Message\Encoding\Filter\Chunk');
19-
}
20-
2117
return 'chunk';
2218
}
2319

src/Encoding/DechunkStream.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ public function getReadFilter()
2424
*/
2525
public function getWriteFilter()
2626
{
27-
if (!array_key_exists('chunk', stream_get_filters())) {
28-
stream_filter_register('chunk', 'Http\Message\Encoding\Filter\Chunk');
29-
}
30-
3127
return 'chunk';
3228
}
3329
}

src/filters.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php
2+
3+
// Register chunk filter if not found
4+
if (!array_key_exists('chunk', stream_get_filters())) {
5+
stream_filter_register('chunk', 'Http\Message\Encoding\Filter\Chunk');
6+
}

0 commit comments

Comments
 (0)