File tree Expand file tree Collapse file tree 5 files changed +25
-16
lines changed
Expand file tree Collapse file tree 5 files changed +25
-16
lines changed Original file line number Diff line number Diff line change @@ -54,15 +54,7 @@ public function runOnce()
5454 $ firstRun = true ;
5555 }
5656
57- try
58- {
59- return $ this ->attemptRun ($ firstRun );
60- }
61- catch (InvalidBufferException $ e )
62- {
63- $ this ->invalidate ();
64- return null ;
65- }
57+ return $ this ->attemptRun ($ firstRun );
6658 }
6759
6860 /**
@@ -82,6 +74,11 @@ private function attemptRun($firstRun)
8274 {
8375 $ data = $ this ->attemptRead ();
8476
77+ if ($ data instanceof EOF )
78+ {
79+ $ this ->invalidate ();
80+ }
81+
8582 if ($ this ->isReading ())
8683 {
8784 return false ;
@@ -155,7 +152,14 @@ private function handleResponse($data)
155152 {
156153 if ($ data instanceof OutputIntent)
157154 {
158- $ this ->write ($ data ->getChannel (), $ data ->getContent ());
155+ try
156+ {
157+ $ this ->write ($ data ->getChannel (), $ data ->getContent ());
158+ }
159+ catch (InvalidBufferException $ e )
160+ {
161+ $ this ->invalidate ();
162+ }
159163 }
160164 if ($ data instanceof ReadIntent)
161165 {
Original file line number Diff line number Diff line change @@ -46,7 +46,5 @@ public function getCommand()
4646
4747 yield new OutputIntent ($ input );
4848 }
49-
50- yield new OutputIntent (new EOF );
5149 }
5250}
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ class Sprunge extends AbstractCommand
2222 */
2323 public function getCommand ()
2424 {
25+
2526 while (true )
2627 {
2728 $ input = (yield new ReadIntent );
@@ -34,9 +35,8 @@ public function getCommand()
3435 $ this ->text .= $ input ;
3536 }
3637
37- $ curl = curl_init ();
38+ $ curl = curl_init (' http://sprunge.us ' );
3839
39- curl_setopt ($ curl , CURLOPT_URL , 'http://sprunge.us ' );
4040 curl_setopt ($ curl , CURLOPT_POST , 1 );
4141 curl_setopt ($ curl , CURLOPT_POSTFIELDS , ['sprunge ' => $ this ->text ]);
4242
Original file line number Diff line number Diff line change @@ -123,7 +123,14 @@ public function read($key)
123123 throw new IOException ("The IOableObject in position ' $ key' does not implement the InputInterface! " );
124124 }
125125
126- return $ this ->ios [$ key ]['channel ' ]->read ();
126+ try
127+ {
128+ return $ this ->ios [$ key ]['channel ' ]->read ();
129+ }
130+ catch (InvalidBufferException $ e )
131+ {
132+ return new EOF ;
133+ }
127134 }
128135
129136 /**
Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ public function run()
5757 {
5858 $ result = $ command ->runOnce ();
5959
60- if ($ result === null )
60+ if ($ result === null || ! $ command -> isValid () )
6161 {
6262 unset($ this ->commands [$ key ]);
6363 }
You can’t perform that action at this time.
0 commit comments