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

If a GET piwik.php is done without any parameter, still return a HTTP 200 #7858

Merged
merged 1 commit into from May 10, 2015

Conversation

tsteur
Copy link
Member

@tsteur tsteur commented May 7, 2015

As soon as it is not a HTTP GET or if there are any parameters given etc we will still return a HTTP 400 do indicate we did actually not track anything

refs #7850

@tsteur tsteur added not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. Needs Review PRs that need a code review labels May 7, 2015
@tsteur tsteur added this to the 2.14.0 milestone May 7, 2015

return strtoupper($requestMethod) === 'GET';
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it would make sense to extract that somewhere global and to reuse it whereever the request method is checked like https://github.com/piwik/piwik/blob/master/core/Tracker.php#L244-L248 or https://github.com/piwik/piwik/blob/master/plugins/Annotations/Controller.php#L109 and so on

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sgiehl we would benefit from a Request object with those kind of basic methods (e.g. 1 or 2), maybe this should be a longer-term refactoring thing?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about this as well but noticed there were no other checks for GET. There were 2 or 3 more cases where a check for POST was done though. The code for this was already in that class anyway so it didn't make anything worse and was ok for me to reuse that existing bit for what we want to achieve. A new class or lib for this would certainly make sense but also requires quite a bit of work (investigating for a good lib to use etc). If we ever use another HTTP client lib it might come out of the box with it etc. Currently, I don't think it's worth the effort or the time spent is better somewhere else but can do if you think so.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree you shouldn't bother with that in the PR. Probably later PSR-7 would stand up as the obvious solution (the PSR will be accepted soon).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good!

@sgiehl
Copy link
Member

sgiehl commented May 9, 2015

Besides the small comment - Looks good :shipit:

@mnapoli
Copy link
Contributor

mnapoli commented May 10, 2015

👍

mnapoli added a commit that referenced this pull request May 10, 2015
If a GET piwik.php is done without any parameter, still return a HTTP 200
@mnapoli mnapoli merged commit 095e3f1 into master May 10, 2015
@mnapoli mnapoli deleted the 7850 branch May 10, 2015 22:31
@gittoar
Copy link

gittoar commented Jul 16, 2015

Hello, why is a HEAD-request not allowed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Review PRs that need a code review not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants