public function readForm()

in php/src/FileFormStream.php [76:133]


    public function readForm($length)
    {
        if ($this->streaming) {
            if (null !== $this->currStream) {
                // @var string $content
                $content = $this->currStream->read($length);
                if (false !== $content && '' !== $content) {
                    fwrite($this->stream, $content);

                    return $content;
                }

                return $this->next("\r\n");
            }

            return $this->next();
        }
        $keysCount = \count($this->keys);
        if ($this->index > $keysCount) {
            return null;
        }
        if ($keysCount > 0) {
            if ($this->index < $keysCount) {
                $this->streaming = true;

                $name  = $this->keys[$this->index];
                $field = $this->form[$name];
                if (!empty($field) && $field instanceof FileField) {
                    if (!empty($field->content)) {
                        $this->currStream = $field->content;

                        $str = '--' . $this->boundary . "\r\n" .
                            'Content-Disposition: form-data; name="' . $name . '"; filename="' . $field->filename . "\"\r\n" .
                            'Content-Type: ' . $field->contentType . "\r\n\r\n";
                        $this->write($str);

                        return $str;
                    }

                    return $this->next();
                }
                $val = $field;
                $str = '--' . $this->boundary . "\r\n" .
                    'Content-Disposition: form-data; name="' . $name . "\"\r\n\r\n" .
                    $val . "\r\n";
                fwrite($this->stream, $str);

                return $str;
            }
            if ($this->index == $keysCount) {
                return $this->next('--' . $this->boundary . "--\r\n");
            }

            return null;
        }

        return null;
    }