#5801 closed enhancement (fixed)
Let XMLHttp-requests send the X-Requested-With header
Reported by: | guest | Owned by: | James Burke |
---|---|---|---|
Priority: | high | Milestone: | 1.1 |
Component: | IO | Version: | 1.0 |
Keywords: | Cc: | ||
Blocked By: | Blocking: |
Description
jQuery, Prototype, YUI and - as it seems - Mootools send the header "X-Requested-With: XMLHttpRequest" with their XHRs. This is a quite convenient feature as it allows the server side to detect whether the current request is a partial request or not. Not only the client side is supported, also popular frameworks like Ruby on Rails, the Zend Framework and CakePHP support that header and expose functionality to the developer. I would really like to have Dojo send that header too.
Change History (8)
comment:1 Changed 12 years ago by
comment:2 Changed 12 years ago by
I would vote for passing it per default as it is an acceptable behaviour a number of JS libraries share. If this is not possible, a config flag would do it for me.
comment:3 Changed 12 years ago by
Alex thanks for the header tip cause it will come handy (using dojo with rails so it will solve some problems... :) ). I belive it would be nice/good/cool/etc if dojo had this as default since all the other (or most of them) js libraries/frameworks do it. Just my two cents :)
comment:4 Changed 12 years ago by
Milestone: | → 1.1 |
---|
Not sure if this is a good idea, since all our IO transports, dojo.io.script, dojo.io.iframe and dojo.xhr use common setup code. It does not seem right to send this for the non-xhr calls.
Instead of a djConfig flag, I suggest this call (works as of Dojo 1.1 -- that version defines the generic dojo.xhr() call that all xhr requests pass through):
dojo.connect(dojo, "xhr", function(args){ if(!args.headers){ args.headers = {}; } args.headers[""] = ["dojoXhr"]; });
comment:5 Changed 12 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:6 Changed 12 years ago by
Ugh, ignore my comment above about it not being a good idea. I implemented it to keep parity with other toolkits.
comment:7 Changed 12 years ago by
Excellent! Thanks for implementing this jburke! :)
Do we know when this is going to be on a release package?
comment:8 Changed 12 years ago by
It will be part of the final 1.1 release. If we do any 1.1 betas (after beta2) or any release candidates, it will be in those builds too.
just pass the "headers" parameter. e.g.:
Does that solve it for you? or are you looking for something like a djConfig flag?