-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set Content-Length for HEAD request manually #2690
Labels
Comments
From #958 , I know that swoole would set |
This does not conform to the HTTP RFC |
From the manual, one way I can come up with: $http->on('request', function ($req, swoole_http_response $resp) use ($http, $data) {
$resp->header('Content-Type', 'application/json');
if ($req->server['request_method'] == 'HEAD') {
$resp->detach();
$length = strlen($data);
$http->send($resp->fd, "HTTP/1.1 200 OK\r\nContent-Length: {$length}\r\nServer: server\r\n\r\n");
return;
}
$resp->end($data);
}); But is there a nicer way? |
sorry, I didn't notice this was a HEAD request, we need to support it |
@twose Many thanks for your quick response! |
springleng
referenced
this issue
in hyperf/hyperf
Jul 16, 2019
Fixed proxy of guzzle client does not work expected.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello, thanks for this amazing project.
But I'm making a HEAD request to check the
Content-Length
field in the headers, but swoole won't acceptContent-Length
field. I don't want to flush the full content to swoole or I don‘t have the content but I do have the content length. How can I do that?Please answer these questions before submitting your issue. Thanks!
Content-Length: 51
Content-Length: 0
php --ri swoole
)?4.4.1-alpha
PHP 7.2.16
The text was updated successfully, but these errors were encountered: