aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/http/lib/Sapi.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/sabre/http/lib/Sapi.php')
-rw-r--r--vendor/sabre/http/lib/Sapi.php24
1 files changed, 14 insertions, 10 deletions
diff --git a/vendor/sabre/http/lib/Sapi.php b/vendor/sabre/http/lib/Sapi.php
index f8e8397fc..4c8fb6732 100644
--- a/vendor/sabre/http/lib/Sapi.php
+++ b/vendor/sabre/http/lib/Sapi.php
@@ -4,8 +4,6 @@ declare(strict_types=1);
namespace Sabre\HTTP;
-use InvalidArgumentException;
-
/**
* PHP SAPI.
*
@@ -115,6 +113,12 @@ class Sapi
if ($copied <= 0) {
break;
}
+ // Abort on client disconnect.
+ // With ignore_user_abort(true), the script is not aborted on client disconnect.
+ // To avoid reading the entire stream and dismissing the data afterward, check between the chunks if the client is still there.
+ if (1 === ignore_user_abort() && 1 === connection_aborted()) {
+ break;
+ }
$left -= $copied;
}
} else {
@@ -162,7 +166,7 @@ class Sapi
$url = $value;
break;
- // These sometimes show up without a HTTP_ prefix
+ // These sometimes show up without a HTTP_ prefix
case 'CONTENT_TYPE':
$headers['Content-Type'] = $value;
break;
@@ -170,21 +174,21 @@ class Sapi
$headers['Content-Length'] = $value;
break;
- // mod_php on apache will put credentials in these variables.
- // (fast)cgi does not usually do this, however.
+ // mod_php on apache will put credentials in these variables.
+ // (fast)cgi does not usually do this, however.
case 'PHP_AUTH_USER':
if (isset($serverArray['PHP_AUTH_PW'])) {
$headers['Authorization'] = 'Basic '.base64_encode($value.':'.$serverArray['PHP_AUTH_PW']);
}
break;
- // Similarly, mod_php may also screw around with digest auth.
+ // Similarly, mod_php may also screw around with digest auth.
case 'PHP_AUTH_DIGEST':
$headers['Authorization'] = 'Digest '.$value;
break;
- // Apache may prefix the HTTP_AUTHORIZATION header with
- // REDIRECT_, if mod_rewrite was used.
+ // Apache may prefix the HTTP_AUTHORIZATION header with
+ // REDIRECT_, if mod_rewrite was used.
case 'REDIRECT_HTTP_AUTHORIZATION':
$headers['Authorization'] = $value;
break;
@@ -220,11 +224,11 @@ class Sapi
}
if (null === $url) {
- throw new InvalidArgumentException('The _SERVER array must have a REQUEST_URI key');
+ throw new \InvalidArgumentException('The _SERVER array must have a REQUEST_URI key');
}
if (null === $method) {
- throw new InvalidArgumentException('The _SERVER array must have a REQUEST_METHOD key');
+ throw new \InvalidArgumentException('The _SERVER array must have a REQUEST_METHOD key');
}
$r = new Request($method, $url, $headers);
$r->setHttpVersion($httpVersion);