@trigger_error('The '.__NAMESPACE__.'\ContentLengthPlugin class is deprecated since version 1.1 and will be removed in 2.0. Use Http\Client\Common\Plugin\ContentLengthPlugin instead.', E_USER_DEPRECATED);
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.
If you suppress an error, we recommend checking for the error condition explicitly:
// For example instead of@mkdir($dir);// Better useif(@mkdir($dir)===false){thrownew\RuntimeException('The directory '.$dir.' could not be created.');}
Loading history...
6
7
use Http\Message\Encoding\ChunkStream;
8
use Psr\Http\Message\RequestInterface;
9
10
/**
11
* Allow to set the correct content length header on the request or to transfer it as a chunk if not possible.
The interface Http\Client\Plugin\Plugin has been deprecated with message: since since version 1.1, and will be removed in 2.0. Use {@link \Http\Client\Common\Plugin} instead.
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be
removed from the class and what other constant to use instead.
Loading history...
18
{
19
/**
20
* {@inheritdoc}
21
*/
22
2
public function handleRequest(RequestInterface $request, callable $next, callable $first)
23
{
24
2
if (!$request->hasHeader('Content-Length')) {
25
2
$stream = $request->getBody();
26
27
// Cannot determine the size so we use a chunk stream
If you suppress an error, we recommend checking for the error condition explicitly: