/** * Wait end of transfer packet to complete * @param $data */ public function parseChunk($data) { if (!$data) { return; } // Detect end of transfer if ($end = strpos($data, "0\r\n\r\n")) { $data = substr($data, 0, $end); } $this->buffer .= $data; $this->request->onData($data); if ($end) { $this->buffer = $this->parseChunkedBuffer($this->buffer); $this->request->setBody($this->buffer); $this->notifyCompleted(); $this->buffer = ''; } }