Aerys\BodyParser::stream PHP Method

stream() public method

public stream ( string $name, integer $size ) : FieldBody
$name string field name
$size integer <= 0: use last size, if none present, count toward total size, else separate size just respecting value size
return FieldBody
    public function stream(string $name, int $size = 0) : FieldBody
    {
        if ($this->req) {
            if ($size > 0) {
                if (!empty($this->curSizes)) {
                    foreach ($this->curSizes[$name] as $partialSize) {
                        $size -= $partialSize;
                        if (!isset($this->sizes[$name])) {
                            $this->usedSize -= $partialSize - \strlen($name);
                        }
                    }
                }
                $this->sizes[$name] = $size;
                $this->body = $this->req->getBody($this->totalSize += $size);
            }
            if (!$this->parsing) {
                $this->parsing = true;
                \Amp\immediately(function () {
                    return $this->initIncremental();
                });
            }
            if (empty($this->bodies[$name])) {
                $this->bodyPromisors[$name][] = [$body = new Deferred(), $metadata = new Deferred()];
                return new FieldBody($body->promise(), $metadata->promise());
            }
        } elseif (empty($this->bodies[$name])) {
            return new FieldBody(new Success(), new Success([]));
        }
        $key = key($this->bodies[$name]);
        $ret = $this->bodies[$name][$key];
        unset($this->bodies[$name][$key], $this->curSizes[$name][$key]);
        return $ret;
    }