Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Request::forge()->set_method('POST')->execute() not setting Input::method() == 'POST'
  • It would appear the expected behavior of Request::set_method('POST') is to set the request so that the receiving route things it's an Input::method() == 'POST' request but it seems to remain as GET. The Request::active()->get_method() returns POST() but this doesn't help with my valdation of data since the validation run process checks for the method to be POST via Input::method() vs. Request::active()->get_method(). What is expected behavior here? I was envisioning Request::forge() as a cURL replacement for triggering controllers in your app from other controllers and tasks.
  • I've already looked at it, but it's not that easy. Request::get_method() calls Input::method() if no request method is defined. And Input::method() should call Request::get_method() as the preferred method to return. This will cause an endless loop if no request method is defined, so the method needs to be decoupled from Input, so the request method will always be the source, and Input::method is just an alias to get the method from the current active request.
  • I've already looked at it, but it's not that easy. Request::get_method() calls Input::method() if no request method is defined. And Input::method() should call Request::get_method() as the preferred method to return. This will cause an endless loop if no request method is defined, so the method needs to be decoupled from Input, so the request method should always be the source, and Input::method is just an alias to get the method from the current active request. Issue with that is that Input::method() is called before the main request is instantiated, so that should be looked at as well.
  • It can't set Input::method(), because that is a global method, so it would destroy the method of all other requests. Better would be that Input::method() would check for a request method before using the global value. Could you create an issue for this at https://github.com/fuel/core/issues so it can be addressed?
  • I can. I wouldn't mind giving a shot at updating it and sending a pull request. I've not really done that before so I'm not sure how it will go. I noticed that the validation method also uses the Input class for getting vars during the validation so it would need to do that too. Is what you're recommending that if a user invokes Input::method() that input method should first check the request method to see if anything exists there and return that if it does. And smiliarly with Input::post('var') should check the request parameters also, because I also assumed that a Request::forge('endpoint')->set_method('POST')->execute(array('var'=>'value1')) would have an Input::post('var') equal to value1 but I had to dig into the Request method to pull out those params so the method I had setup that is normally exeucted from a form submit or ajax post could not be used the same way internally using a Request::forge().... call.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion