Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP verb rules in router are NOT case-insensitive #4027

Closed
jagandecapri opened this issue Aug 5, 2015 · 1 comment
Closed

HTTP verb rules in router are NOT case-insensitive #4027

jagandecapri opened this issue Aug 5, 2015 · 1 comment
Labels
Milestone

Comments

@jagandecapri
Copy link

The docs http://www.codeigniter.com/user_guide/general/routing.html?highlight=rest#using-http-verbs-in-routes says that HTTP verb rules are case-insensitive and proceeds to give these examples.

$route['products/(:num)']['DELETE'] = 'product/delete/$1';
$route['products']['put'] = 'product/insert'

But, when I try to use capitalized HTTP verb such as POST etc, 404 error is shown.
Looking through function _parse_routes() in system/core/Router.php.

$http_verb = isset($_SERVER['REQUEST_METHOD']) ? strtolower($_SERVER['REQUEST_METHOD']) : 'cli';
....
elseif (is_array($this->routes[$uri]) && isset($this->routes[$uri][$http_verb]))

HTTP verbs from the $_SERVER is changed into lowercase before the $this->routes array is checked.
Hence, only lower case HTTP verbs seems to be working, contradicting with the docs.

@narfbg narfbg closed this as completed in abc299b Aug 5, 2015
@jagandecapri
Copy link
Author

Thanks @narfbg for the quick fix. 👍

@narfbg narfbg added the Bug label Aug 6, 2015
@narfbg narfbg added this to the 3.0.1 milestone Aug 14, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants