Atmosphere/atmosphere — Issue #191: undefined 'headers' in jquery.atmosphere.js v0.9
Author: ncolomer
Created: 2012-02-19 14:48:35+00:00
State: open

I try to attach headers when subscribing to my push uri using :

$.atmosphere.subscribe(url, callback, $.atmosphere.request = {
attachHeadersAsQueryString: true,
transport: 'websocket',
headers: {"X-My-Header": header}
});

But this throw an `Uncaught TypeError: Cannot read property 'headers' of undefined` at line 498 of jquery.atmosphere.js.

A quick look at the code shows it tries to iterate on `request.headers` whereas `request` var is not defined locally.
The correct defined var in `_attachHeaders(request)` function is `rq` (see line 470: `var rq = _request;`) and should be used instead.

This would be fixed by replacing line 498 :
`jQuery.each(request.headers, function(name, value) {`
By :
`jQuery.each(rq.headers, function(name, value) {`

Test was done with:
- Atmosphere framework 0.9-SNAPSHOT
- Atmosphere jQuery plugin v0.9
- Google Chrome 17.0.963.46