Bug #51763
HttpRequest always returns content of the current request
Status: | New | Start date: | 2013-09-05 | |
---|---|---|---|---|
Priority: | Should have | Due date: | ||
Assigned To: | - | % Done: | 0% |
|
Category: | Http | |||
Target version: | - | |||
PHP Version: | Complexity: | |||
Has patch: | No | Affected Flow version: | Flow 2.0.0 |
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:
1$request = \TYPO3\Flow\Http\Request::create(new \TYPO3\Flow\Http\Uri($uri), $method, $arguments); 2$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:
1$content = $request->getContent(); 2// ... 3$body = $content !== '' ? $content : http_build_query($request->getArguments()); 4curl_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:
1if ($this->content === NULL) { 2 $this->content = file_get_contents($this->inputStreamUri); 3}
A nasty work around is to call $request->setContent('') after creating the request object in the client code..
History
#1 Updated by Ferdinand Kuhl 5 months 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.