[OpenLayers-Users] I'm stuck trying to decorate OpenLayers.Request.issue

Stephen Woodbridge woodbri at swoodbridge.com
Fri Feb 1 18:21:32 PST 2013


Hi All,

I am trying to add some tracking code to my OpenLayers app so I can 
track performance of ajax requests. So my plan was to decorate the 
OpenLayers.Request.issue function to log the time before and after the 
issue().

Something like:

function decorateOpenLayersAjax(f) {
   var startT = new Data();
   var answer = f.apply(this, arguments);
   try {
     var deltaT = ((new Date()).getTime() - startT.getTime())/1000.0;
     logtime(deltaT);
   }
   finally {
     return answer;
   }
}

And then in my init() function:

OpenLayers.Request.issue = decorateOpenLayersAjax(OpenLayers.Request.issue);

My page loads fine, but on the first ajax request I get the error:

TypeError: a.headers is undefined

which implies that my decoration is breaking the code in:

"ol212/lib/OpenLayers/Request.js" line 165

     issue: function(config) {
         // apply default config - proxy host may have changed
         var defaultConfig = OpenLayers.Util.extend(
             this.DEFAULT_CONFIG,
             {proxy: OpenLayers.ProxyHost}
         );
         config = OpenLayers.Util.applyDefaults(config, defaultConfig);

It seems that this.DEFAULT_CONFIG no longer points to the original 
object where it is defined.

Any ideas on how to do this, or a better way to do this would be 
appreciated.

-Steve


More information about the Users mailing list