public function __construct($callback) { parent::__construct($callback); list($headers, $text) = explode("\r\n\r\n", $this->value, 2); if (strpos($headers, ' 100 Continue') !== false) { list($headers, $text) = explode("\r\n\r\n", $text, 2); } # parse the headers $headers = explode("\n", str_replace("\r", '', $headers)); foreach ($headers as $header) { $header = explode(': ', $header); if (count($header) === 2) { $this->headers[$header[0]] = $header[1]; } } $this->text = $text; $this->value = $this; }
public function __construct($callback, Http $client = null) { parent::__construct($callback); $this->client = $client; }
public function testFinallyAfterReject() { $phpunit = $this; $promise = new Promise(function ($resolve, $reject) { $reject(0); }); $promise->then(function ($data) use($phpunit) { $phpunit->fail('This should not run!'); }, function ($data) use($phpunit) { $phpunit->assertEquals($data, 0); return $data + 1; })->catch(function ($data) use($phpunit) { $phpunit->assertEquals($data, 1); return $data + 1; })->finally(function ($data) use($phpunit) { $phpunit->assertEquals($data, 2); }); }
public function __construct($callback, Http $client = null, Session $session = null) { parent::__construct($callback); $this->client = $client; $this->session = $session; }