Bug #51763

HttpRequest always returns content of the current request

Added by Bastian Waidelich about 8 years ago. Updated over 6 years ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
Http
Target version:
-
Start date:
2013-09-05
Due date:
% Done:

0%

Estimated time:
PHP Version:
Has patch:
No
Complexity:

Description

This is a bit hard to describe and I'm not 100% sure whether this is a bug in the Http\Request or in the calling code:

When using The \TYPO3\Flow\Http\Client\Browser like this:

$request = \TYPO3\Flow\Http\Request::create(new \TYPO3\Flow\Http\Uri($uri), $method, $arguments);
$response = $this->browser->sendRequest($request);

The default request engine (= CurlEngine) ignores $arguments and instead sends the content of the current request!

The reason for this is following code in CurlEngine:

$content = $request->getContent();
// ...
$body = $content !== '' ? $content : http_build_query($request->getArguments());
curl_setopt($curlHandle, CURLOPT_POSTFIELDS, $body);

So the engine prefers the request body over its arguments (which I think is correct) – the issue seems to be that Http\Request::getContent() returns the current input stream:

if ($this->content === NULL) {
    $this->content = file_get_contents($this->inputStreamUri);
}

A nasty work around is to call $request->setContent('') after creating the request object in the client code..

#1

Updated by Ferdinand Kuhl over 6 years ago

That is still the case.

If I overwrite Request with an own class, not reading from inputStreamUri the POST-Parameter gets send as expected, BUT the Content-Length-Header is not updated, confusing the receiving Webserver.

Also available in: Atom PDF