Skip to content

[Feature request?] Support Transfer-Encoding chunked with no Content-Length #1120

Description

@krissss

目前上传未知大小的流式数据,服务端会报 400 错误(HTTP/1.1 400 Bad Request\r\nContent-Length: 0\r\n\r\n)。
发现原因是代码中做了 header 中必须有 Content-Length 的限制(Workerman\Protocols\Http::input 内)。
但是当上传未知大小的数据时,仅使用 Transfer-Encoding: chunked 是符合标准的。
希望支持下。

测试代码:
客户端:

$fp = fopen('php://temp', 'r+');
fwrite($fp, 'hello');
$response = \Symfony\Component\HttpClient\HttpClient::create()
    ->request('POST', 'http://127.0.0.1:8787/upload', [
        'body' => $fp
    ]);
dd($response->getStatusCode());

服务端:webman
header 头信息打印(打印位置:Workerman\Protocols\Http::input):

POST /upload HTTP/1.1\r\n
Host: 127.0.0.1:8787\r\n
Accept: */*\r\n
User-Agent: Symfony HttpClient (Curl)\r\n
Accept-Encoding: gzip\r\n
Transfer-Encoding: chunked\r\n
Content-Type: application/x-www-form-urlencoded

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions