fluidinfo/fluidinfo.js — Issue #49: Fix oddness in loop over HEADERS array
Author: terrycojones
Created: 2011-10-28 20:58:16+00:00
State: open

We currently have code that looks like this:

```
var HEADERS = ["Content-Type", "Content-Length", "Location", "Date",
"WWW-Authenticate", "Cache-Control", "X-FluidDB-Error-Class",
"X-FluidDB-Path", "X-FluidDB-Message", "X-FluidDB-ObjectId",
"X-FluidDB-Query", "X-FluidDB-Name", "X-FluidDB-Category",
"X-FluidDB-Action", "X-FluidDB-Rangetype", "X-FluidDB-Fieldname",
"X-FluidDB-Type", "X-FluidDB-Argument", "X-FluidDB-Access-Token",
"X-FluidDB-New-User", "X-FluidDB-Username"];
var h = "";
for(h in HEADERS){
var header = HEADERS[h];
```

I'm not sure that that's the best way to loop through the array (my JS skills are almost zero), but in any case it's producing a weird message in the JS console, which ends like this:

```
Refused to get unsafe header "X-FluidDB-Access-Token"
Refused to get unsafe header "X-FluidDB-New-User"
Refused to get unsafe header "X-FluidDB-Username"
Refused to get unsafe header "function (val) {
for (var i = this.length; i--;) {
if (this[i] == val) {
return true;
}
}
return false;
}"
```

so I think the `for h in HEADERS` is picking up some property of the array (which looks like a find function) and trying to get the value of the function (as a string!) as a header.

The error message goes away when I instead use the more normal(?)

```
for (var i = 0; i < HEADERS.length; i++) {
var header = HEADERS[i];
```

So I'm going to make that change in this ticket.