#13240 closed defect (fixed)
JsonRest Store Custom Headers
Reported by: | ahenderson | Owned by: | Kris Zyp |
---|---|---|---|
Priority: | high | Milestone: | 1.8 |
Component: | Data | Version: | 1.7.0b1 |
Keywords: | dojo.store.JsonRest ObjectStore headers queryOptions | Cc: | |
Blocked By: | Blocking: |
Description
Problem:
It is not possible to include custom headers when using the dojo.store.JsonRest? store when wrapped in a dojo.data.ObjectStore?
Scenario:
dojox.grid.DataGrid? -> dojo.data.ObjectStore? -> dojo.store.JsonRest?
I would like to be able to add extra headers to a query:
var query = dojo.formToObject("myForm"); var queryOpts = { headers : { "Custom-Header1" : "hello" } }; grid.setQuery(query,queryOpts));
When I do this my custom header is not included in the request.
This appears to be down to the JsonRest? store not expecting to receive header options while wrapped in a dojo.data.ObjectStore?.
Possible Solution:
A possible solution would be to extract the headers from the options object, supporting the dojo.store or dojo.data.store api
dojo.store.JsonRest?.js
query : function(query, options) { options = options || {}; var headers = options.headers || options.queryOptions.headers || {}; headers.Accept = "application/javascript, application/json"; ...
Will also affect the put method as well.
Change History (4)
comment:1 Changed 10 years ago by
Owner: | changed from Jared Jurkiewicz to Kris Zyp |
---|
comment:2 Changed 9 years ago by
comment:3 Changed 9 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
I believe this was fixed with [28877]
comment:4 Changed 9 years ago by
Milestone: | tbd → 1.8 |
---|
I'd like to upvote this issue. I just found that one cannot pass custom headers into JsonRest?.query() when calling it directly. Also, the get() second argument, 'options', is poorly named and undocumented at http://dojotoolkit.org/reference-guide/1.7/dojo/store.html or http://dojotoolkit.org/reference-guide/1.7/dojo/store/JsonRest.html.
Please, the ability to pass custom headers would be extremely useful. I'm going to have to either stick to passing my security tokens in the query parameters, where it doesn't belong, or create a derived JsonRest? store with a completely replaced query() function, which isn't optimal.
Is there a fix for this in the works, perhaps aimed for 1.8, or is nothing being done? No update on this ticket for 11 months is worrying.