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

adding isAjax() method to Request. #236

Closed
wants to merge 1 commit into from

Conversation

andreyvital
Copy link

No description provided.

@Rican7 Rican7 added the Feature label Oct 6, 2014
@Rican7 Rican7 self-assigned this Oct 6, 2014
@Rican7 Rican7 added this to the 2.1 milestone Oct 6, 2014
@unstoppablecarl
Copy link

@Rican7
Copy link
Member

Rican7 commented Oct 6, 2014

The tests did die on your new addition, if you check the output here.
Its because of your non PSR-2 compliant code style (your foreach( needs to be a foreach (). You're also using short-array syntax (5.4+ only) in a PHP 5.3 compatible library, which won't pass.

As far as why I tagged this as "May Not Implement", its because I wanted to do some more research into the reliability of this method checking an actual AJAX call. I've found out a few things:

  • I nearly forgot, but we've talked about detecting XHR before
  • Checking based on a header alone isn't reliable, as the header could be manually overwritten. The use case I see most often applying this feature request to is for some layer of security checking, and this would be a false security measure
  • The X-Requested-With header is non-standard (hence the X- prefix), and is not implemented by most browsers. This header is mostly a jQuery thing, and other frameworks/libraries that have used it in the past have since removed it

So, as you can see, this method would be a nice convenience if it were accurate/dependable. Unfortunately, its based on something added in by a particular JavaScript framework, and therefore isn't something I think would make sense to add to the base library.

@andreyvital andreyvital closed this Oct 6, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants