This repository was archived by the owner on Jan 29, 2020. It is now read-only.
This repository was archived by the owner on Jan 29, 2020. It is now read-only.
HTTP/1.1 response to the Client of 1.0 #502
Open
Description
# create project from zend-expressive-skeleton
composer create-project zendframework/zend-expressive-skeleton .
# run container
docker run --rm -p 8080:80 -v "$PWD:/app" -w "/app" php:apache sh -c '
a2enmod rewrite
rmdir /var/www/html
ln -s /app/public /var/www/html
exec apache2-foreground
'
# run curl in other terminal, and see response
curl -i -0 http://localhost:8080/
curl request is HTTP/1.0, but zend-expressive has HTTP/1.1 response.
HTTP/1.1 200 OK
Date: Wed, 26 Jul 2017 10:46:48 GMT
Server: Apache/2.4.10 (Debian)
X-Powered-By: PHP/7.1.7
Content-Length: 151
Content-Type: application/json
:
Next, I tried ApacheBench.
ab -c 1 -n 1 http://localhost:8080/
Very very slow.
:
Requests per second: 0.20 [#/sec] (mean)
Time per request: 5021.594 [ms] (mean)
Time per request: 5021.594 [ms] (mean, across all concurrent requests)
:
ApacheBench expect active close of server, but server does not close until KeepAliveTimeout seconds.
This problem can solved by fix response protocol version based on request protocol version.
// pipeline.php
use Psr\Http\Message\ServerRequestInterface;
use Interop\Http\ServerMiddleware\DelegateInterface;
$app->pipe(function (ServerRequestInterface $request, DelegateInterface $delegate) {
return $delegate->process($request)->withProtocolVersion($request->getProtocolVersion());
});
Metadata
Metadata
Assignees
Labels
No labels