diff --git a/basis/io/ports/ports-tests.factor b/basis/io/ports/ports-tests.factor index 9fb5a5826b..ae63b650d9 100644 --- a/basis/io/ports/ports-tests.factor +++ b/basis/io/ports/ports-tests.factor @@ -1,6 +1,8 @@ USING: accessors alien.c-types alien.data destructors io -io.directories io.encodings.ascii io.encodings.binary io.files -io.files.temp io.pipes kernel libc math sequences tools.test ; +io.directories io.encodings.ascii io.encodings.binary +io.encodings.string io.encodings.utf8 io.files io.files.temp +io.pipes io.sockets kernel libc math namespaces sequences +tools.test ; IN: io.ports.tests ! Make sure that writing malloced storage to a file works, and @@ -29,3 +31,12 @@ IN: io.ports.tests [ +byte+ ] [ binary [ out>> stream-element-type ] with-disposal ] unit-test [ +character+ ] [ ascii [ stream-element-type ] with-disposal ] unit-test [ +character+ ] [ ascii [ out>> stream-element-type ] with-disposal ] unit-test + +! Issue #1256 regression test +! Port length would be zero before data is received +{ f } [ + "google.com" 80 binary [ + "GET /\n" utf8 encode write flush + input-stream get stream-contents + ] with-client empty? +] unit-test diff --git a/basis/io/ports/ports.factor b/basis/io/ports/ports.factor index 8646d3b609..208e023e08 100644 --- a/basis/io/ports/ports.factor +++ b/basis/io/ports/ports.factor @@ -208,8 +208,9 @@ M: output-port stream-seek M: buffered-port stream-seekable? handle>> can-seek-handle? ; +! Cannot be ``handle>> handle-length`` because of a race condition. M: buffered-port stream-length - handle>> handle-length ; + drop f ; GENERIC: shutdown ( handle -- )