| 131 | | setRequestHeaders: function() { |
|---|
| 132 | | var headers = { |
|---|
| 133 | | 'X-Requested-With': 'XMLHttpRequest', |
|---|
| 134 | | 'X-Prototype-Version': Prototype.Version, |
|---|
| 135 | | 'Accept': 'text/javascript, text/html, application/xml, text/xml, */*' |
|---|
| 136 | | }; |
|---|
| | 131 | setRequestHeaders: (function(){ |
|---|
| | 132 | |
|---|
| | 133 | var acceptHeader = $w('text/javascript text/html '+ |
|---|
| | 134 | (Prototype.Browser.IE? '' : 'application/xhtml+xml ')+ |
|---|
| | 135 | 'application/xml text/xml application/json */*').join(', '); |
|---|
| | 136 | |
|---|
| | 137 | return function(){ |
|---|
| | 138 | var headers = { |
|---|
| | 139 | 'X-Requested-With': 'XMLHttpRequest', |
|---|
| | 140 | 'X-Prototype-Version': Prototype.Version, |
|---|
| | 141 | 'Accept': acceptHeader |
|---|
| | 142 | }; |
|---|
| 142 | | /* Force "Connection: close" for older Mozilla browsers to work |
|---|
| 143 | | * around a bug where XMLHttpRequest sends an incorrect |
|---|
| 144 | | * Content-length header. See Mozilla Bugzilla #246651. |
|---|
| 145 | | */ |
|---|
| 146 | | if (this.transport.overrideMimeType && |
|---|
| 147 | | (navigator.userAgent.match(/Gecko\/(\d{4})/) || [0,2005])[1] < 2005) |
|---|
| 148 | | headers['Connection'] = 'close'; |
|---|
| 149 | | } |
|---|
| 150 | | |
|---|
| 151 | | // user-defined headers |
|---|
| 152 | | if (typeof this.options.requestHeaders == 'object') { |
|---|
| 153 | | var extras = this.options.requestHeaders; |
|---|
| | 148 | /* Force "Connection: close" for older Mozilla browsers to work |
|---|
| | 149 | * around a bug where XMLHttpRequest sends an incorrect |
|---|
| | 150 | * Content-length header. See Mozilla Bugzilla #246651. |
|---|
| | 151 | */ |
|---|
| | 152 | if (this.transport.overrideMimeType && |
|---|
| | 153 | (navigator.userAgent.match(/Gecko\/(\d{4})/) || [0,2005])[1] < 2005) |
|---|
| | 154 | headers['Connection'] = 'close'; |
|---|
| | 155 | } |
|---|
| 162 | | for (var name in headers) |
|---|
| 163 | | this.transport.setRequestHeader(name, headers[name]); |
|---|
| 164 | | }, |
|---|
| | 161 | if (Object.isFunction(extras.push)) |
|---|
| | 162 | for (var i = 0, length = extras.length; i < length; i += 2) |
|---|
| | 163 | headers[extras[i]] = extras[i+1]; |
|---|
| | 164 | else |
|---|
| | 165 | $H(extras).each(function(pair) { headers[pair.key] = pair.value }); |
|---|
| | 166 | } |
|---|
| | 167 | |
|---|
| | 168 | for (var name in headers) |
|---|
| | 169 | this.transport.setRequestHeader(name, headers[name]); |
|---|
| | 170 | } |
|---|
| | 171 | })(), |
|---|