Cache put parameters in CHttpRequest getRestParams method

Hello,

My request is to cache the PUT parameters of a request.

[size="3"]CURRENT IMPLEMENTATION[/size]

The way the PUT parameters are currently being read is by parsing the php://input stream (see the implementation)

According to the php documentation regarding the php://input stream, this stream can be read only once (pay attention to the NOTE section in the php documentation).

My tests have also shown that I can successfully get the PUT params once, but not twice, by calling:


Yii::app()->getRequest()->restParams

[size="3"]REASONING[/size]

I am developing a Yii based REST based web service and I want to implement authentication. Part of my authentication scheme (which imitates the authentication used in the Amazon AWS REST API calls) is to calculate a signature of the incoming request parameters (among other things).

This requires me to get the PUT parameters ONCE during the authentication process (done in a filter that runs before my controller) and then a SECOND time during the implementation of the PUT request.

Unfortunately, by the time the actual PUT request gets it’s opportunity to execute, I have lost access to the PUT parameters (since they are consumed by the authentication check).

[size="3"]SOLUTION[/size]

I would suggest that the PUT parameters are cached, during their first request, and then served from the cached variable in any subsequent requests.

I could also cache the PUT parameters somewhere in my application (something I am trying to work on now) but I think that this should be a responsibility of the framework and not mine.

[size="3"]COMMENTS[/size]

Hopefully, I have not misread the documentation and it would be quite embarrassing if there IS a way to repeatedly get the PUT parameters.

I welcome any suggestions on alternative ways to approach this situation.

Thanks,

Stratos

For those interested I have already filled a bug report on google code and I also submitted a patch that fixes the issue.