1
0
mirror of https://github.com/danog/byte-stream.git synced 2024-12-02 09:17:50 +01:00
Commit Graph

155 Commits

Author SHA1 Message Date
ff425ff87c
Update functions.php 2019-08-23 22:54:35 +02:00
b3e9bdb04f cs-fix 2019-08-23 15:08:20 +02:00
0f3d1ae5b1 Merge 2019-08-23 00:03:18 +02:00
Niklas Keller
1b84c81bb2
Add line delimited JSON parser (#65) 2019-08-22 23:36:28 +02:00
5d3fd73325 Add stdinbuffer 2019-08-22 22:58:19 +02:00
ce038f298d Rename 2019-08-22 22:44:03 +02:00
4b7bd7b8ee Rename 2019-08-22 22:42:20 +02:00
Niklas Keller
38d13dbb5c
Add LineReader (#64) 2019-08-22 22:37:48 +02:00
010c215c4b Add warning 2019-08-22 22:20:51 +02:00
e8e41f3882 Merge remote-tracking branch 'o/line-reader' 2019-08-22 22:14:39 +02:00
Niklas Keller
ff5aa41e5f Add LineReader::getBuffer() 2019-08-22 22:09:47 +02:00
Niklas Keller
94f4322c7d Fix LineReader order 2019-08-22 21:57:02 +02:00
27034fc345 Readd b flag 2019-08-22 21:47:29 +02:00
ea01c9a051 Refactor 2019-08-22 21:45:16 +02:00
1b3c043451 Merge remote-tracking branch 'o/line-reader' 2019-08-22 21:41:01 +02:00
fdc28ee816 Merge 2019-08-22 21:39:45 +02:00
Niklas Keller
bb5e38722e Move LineReaderTest to correct directory 2019-08-22 21:04:24 +02:00
Niklas Keller
a0a418e01e Add LineReader
Closes #63.
2019-08-22 20:55:09 +02:00
Aaron Piotrowski
47908f8e8b
Return Failure instead of throwing
Closure should fail returned promise, not throw directly from method call.
2019-07-26 16:22:49 -05:00
eaec19ea30 Add async readline/echo and add composer commands 2019-07-15 16:16:07 +02:00
Niklas Keller
c75af3778b
Fix ResourceOutputStream closed detection (#60)
The previous mechanism with feof doesn't work for systemd launched processes.

Fixes #58.
2019-06-03 23:45:17 +02:00
Niklas Keller
33daa23ab1 Add 'b' flag to web SAPI streams 2019-06-03 23:05:11 +02:00
d8cc314d62 Add web SAPI input/output stream getter functions (#61) 2019-06-03 23:01:43 +02:00
e7bde57f91 Last name change 2019-06-02 11:38:15 +02:00
a7b2cc8d95 Change function names 2019-06-01 13:21:06 +02:00
bc191a8380 phpcs fix 2019-05-21 15:45:27 +02:00
94caa13d49 Add web input/output stream getter functions 2019-05-21 15:40:32 +02:00
Gabriel Ostrolucký
d5cd42a765 Add chunksize setter to Resource*Stream classes (#55)
Fixes #50.
2019-03-31 16:51:36 +02:00
Niklas Keller
2120bdd46b Revert "Throw new exception carrying $chunk when fwrite returns 0"
This reverts commit eb4d03504d.

The previous commit was incomplete and needs additional work.
2019-03-11 20:12:45 +01:00
Gabriel Ostrolucký
eb4d03504d
Throw new exception carrying $chunk when fwrite returns 0 2019-03-05 00:11:39 +01:00
Niklas Keller
3a4e493d39 Change #47 test case 2018-12-25 13:13:28 +01:00
Niklas Keller
37b9ab16bb
Solve performance issues with very large chunks
Very large chunks need to be copied every time there's a partial write, which is pretty problematic. Instead of doing an almost full copy of the full chunk every time, this patch splits very large chunks into multiple smaller chunks automatically.

Fixes #41.
2018-10-22 14:37:37 -05:00
Aaron Piotrowski
2dda482685 Add getStd*() functions 2018-10-22 20:36:00 +02:00
Niklas Keller
d161589772 Apply PSR-2 2018-09-22 16:04:00 +02:00
Niklas Keller
a4cf31f089 Add buffer test 2018-09-22 16:04:00 +02:00
Niklas Keller
75aa20de7c Add buffer function
This simplifies buffering streams by not having to construct a Message / Payload object.
2018-09-22 16:04:00 +02:00
Aaron Piotrowski
24b2530ec7
Remove exception overwrite
Copy/paste oversight.
2018-04-05 09:44:39 -05:00
Aaron Piotrowski
da357d1579
Proper fix for remote closed streams
Fixes #40. Streams on MacOS (and possibly FreeBSD) that are closed by the remote still allow writing, returning a non-zero from fwrite(). EOF then is false, since data was written to the buffer. EOF needed to be checked before calling fwrite().
2018-04-03 19:08:18 -05:00
Aaron Piotrowski
33a74dfecd
Fix closed streams that continually report as writable 2018-04-03 11:57:25 -05:00
Niklas Keller
56e814943a Add tests for dead socket detection
Relates to #40.
2018-04-03 18:20:40 +02:00
Aaron Piotrowski
6bd0be750d Add Payload
Similar to Message, but does not implement Promise to avoid all the issues that are associated with that.
2018-03-13 09:53:18 -05:00
Niklas Keller
9f60974881 Fix resource input streams
The read watcher needs to be disabled now, because immediate reads will process the next immediate read now in the next tick.

Fixes #38.
2018-03-11 10:19:43 +01:00
Niklas Keller
062f16d0c5 Defer immediate reads
Immediate reads have been introduced to support in-memory streams and STDIN on Windows, but this causes problems during piping of streams that always have data available, because it blocks everything else. This is resolved by deferring the promise resolution to the next tick.
2018-03-09 17:40:36 +01:00
Niklas Keller
a4739c8a6d Attempt direct read on ResourceInputStream::read()
This change should resolve the low performance on Windows' STDIN. STDIN
on Windows is a file handle and Windows has specialized support built
into it's stream_select implementation, but a stream_select with a file
handle takes 100ms, which results in slow performance if we read in
smaller chunks and always have to wait 100ms between these.

Fixes amphp/socket#52.
2018-03-08 11:38:16 +01:00
Aaron Piotrowski
11da27c603
Only throw if resource closed or at eof 2018-02-09 00:47:09 -06:00
Niklas Keller
2cb8005742 Throw correct exception in ResourceOutputStream after close
Fixes #35.
2018-02-07 13:49:07 +01:00
Niklas Keller
1b0b8daed4 Polyfill STDOUT and STDERR on SAPIs not being CLI
STDERR is used by amphp/parallel for error forwarding from children. STDERR gets written to the error log in case of Apache and similar locations for other SAPIs.

This also ensures STDOUT / STDERR can always be used and only a single stream ID exists for STDOUT / STDERR, which might otherwise error for libuv if people open 'php://stderr' multiple times.

Fixes amphp/parallel-functions#6.
Fixes amphp/parallel#34.
2018-01-12 20:43:00 +01:00
Niklas Keller
0b6d99b2c3 Remove outdated note about closing ResourceInputStreams 2017-12-27 20:13:24 +01:00
Niklas Keller
5dffe33692 Throw correct PendingReadError for IteratorStream 2017-12-22 09:31:37 +01:00
Niklas Keller
0c059ba0e6 Suppress errors also for stream_socket_shutdown, relates to #32 2017-12-10 17:40:58 +01:00