Feature #36217
As a developer I would like to have access to php://input in a uniform way
Status: | Resolved | Start date: | 2012-04-17 | |
---|---|---|---|---|
Priority: | Should have | Due date: | ||
Assigned To: | Robert Lemke | % Done: | 0% |
|
Category: | Environment | |||
Target version: | TYPO3 Flow Base Distribution - 1.1 | |||
PHP Version: | 5.3 | Complexity: | medium | |
Has patch: | No |
Description
When using flow3 to create rest controllers, sometimes you would like to be able to have access to php://input from multiple sources (authentication token, controller and aspect/pointcut might all be relevant places). However if doing a PUT request and trying to read the php://input multiple times, it will return an empty string.
I guess the correct place to have this is in TYPO3\FLOW3\Utility\Environment - and either setting php:/input content to a instance variable in the constructor - or saving the value of the stream on the first read (to save the call to file_get_contents - or similar - to use cases where it is actually used).
I have attaached a quick diff to show what I mean.
History
#1 Updated by Claus Witt over 3 years ago
- File access-to-raw-input.diff added
The first diff had some copied comments from getRawPostArguments
#2 Updated by Bastian Waidelich over 3 years ago
- Category set to Environment
Hi Claus,
Good catch and I think we could implement it the way you suggested.
BTW: Why the "$\" in front of the file_get_content() call?
BTW²: If you're trying to get REST support, you might be interested in the simple REST-Test package I wrote a while ago (It probably needs minor adjustments to the latest code base).
#3 Updated by Robert Lemke over 3 years ago
- Status changed from New to Resolved
- Assigned To set to Robert Lemke
- Target version set to 1.1
- PHP Version set to 5.3
- Complexity changed from easy to medium
This is already implemented in FLOW3 1.1, see FLOW3\Http\Request for more details:
/** * Returns the content of the request body * * @param boolean $asResource If set, the content is returned as a resource pointing to PHP's input stream * @return string|resource * @api */ public function getContent($asResource = FALSE) {