66use Clue \React \Buzz \Message \Response ;
77use Clue \React \Docker \Io \ResponseParser ;
88use React \Promise \PromiseInterface as Promise ;
9+ use Clue \React \Docker \Io \StreamingParser ;
910
1011/**
1112 * Docker Remote API client
@@ -20,6 +21,7 @@ class Client
2021 private $ browser ;
2122 private $ url ;
2223 private $ parser ;
24+ private $ streamingParser ;
2325
2426 /**
2527 * Instantiate new Client
@@ -31,15 +33,20 @@ class Client
3133 * @param ResponseParser|null $parser
3234 * @see Factory::createClient()
3335 */
34- public function __construct (Browser $ browser , $ url , ResponseParser $ parser = null )
36+ public function __construct (Browser $ browser , $ url , ResponseParser $ parser = null , StreamingParser $ streamingParser = null )
3537 {
3638 if ($ parser === null ) {
3739 $ parser = new ResponseParser ();
3840 }
3941
42+ if ($ streamingParser === null ) {
43+ $ streamingParser = new StreamingParser ();
44+ }
45+
4046 $ this ->browser = $ browser ;
4147 $ this ->url = $ url ;
4248 $ this ->parser = $ parser ;
49+ $ this ->streamingParser = $ streamingParser ;
4350 }
4451
4552 /**
@@ -305,10 +312,10 @@ public function imageList($all = false)
305312 */
306313 public function imageCreate ($ fromImage = null , $ fromSrc = null , $ repo = null , $ tag = null , $ registry = null , $ registryAuth = null )
307314 {
308- return $ this ->browser ->post (
315+ return $ this ->streamingParser -> parseResponse ( $ this -> browser ->post (
309316 $ this ->url ('/images/create?fromImage=%s&fromSrc=%s&repo=%s&tag=%s®istry=%s ' , $ fromImage , $ fromSrc , $ repo , $ tag , $ registry ),
310317 $ this ->authHeaders ($ registryAuth )
311- )->then (array ($ this ->parser , 'expectJson ' ));
318+ )) ->then (array ($ this ->parser , 'expectJson ' ));
312319 }
313320
314321 /**
0 commit comments