[Jifty-commit] r4328 - jifty/branches/prototype-1.6/share/web/static/js

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Mon Oct 29 13:04:07 EDT 2007


Author: sunnavy
Date: Mon Oct 29 13:04:06 2007
New Revision: 4328

Modified:
   jifty/branches/prototype-1.6/share/web/static/js/prototype.js

Log:
stop writing stupid stuff to headers

Modified: jifty/branches/prototype-1.6/share/web/static/js/prototype.js
==============================================================================
--- jifty/branches/prototype-1.6/share/web/static/js/prototype.js	(original)
+++ jifty/branches/prototype-1.6/share/web/static/js/prototype.js	Mon Oct 29 13:04:06 2007
@@ -1070,17 +1070,24 @@
       'Accept': 'text/javascript, text/html, application/xml, text/xml, */*'
     };
 
+    var headerNames = [ 'X-Requested-With', 'X-Prototype-Version', 'Accept' ];
+
     if (this.method == 'post') {
-      headers['Content-type'] = this.options.contentType +
-        (this.options.encoding ? '; charset=' + this.options.encoding : '');
+      if ( !this.options.contentType) {
+          headers['Content-Type'] = this.options.contentType +
+            (this.options.encoding ? '; charset=' + this.options.encoding : '');
+          headerNames.push('Content-type');
+      }
 
       /* Force "Connection: close" for older Mozilla browsers to work
        * around a bug where XMLHttpRequest sends an incorrect
        * Content-length header. See Mozilla Bugzilla #246651.
        */
       if (this.transport.overrideMimeType &&
-          (navigator.userAgent.match(/Gecko\/(\d{4})/) || [0,2005])[1] < 2005)
+          (navigator.userAgent.match(/Gecko\/(\d{4})/) || [0,2005])[1] < 2005) {
             headers['Connection'] = 'close';
+            headerNames.push('Connection');
+          }
     }
 
     // user-defined headers
@@ -1088,14 +1095,21 @@
       var extras = this.options.requestHeaders;
 
       if (typeof extras.push == 'function')
-        for (var i = 0, length = extras.length; i < length; i += 2)
+        for (var i = 0, length = extras.length; i < length; i += 2) {
           headers[extras[i]] = extras[i+1];
+          headerNames.push(extras[i]);
+        }
       else
-        $H(extras).each(function(pair) { headers[pair.key] = pair.value });
+        $H(extras).each(function(pair) { 
+            headers[pair.key] = pair.value 
+            headerNames.push(pair.key);
+        });
+    }
+    
+    for (var i=0; i<headerNames.length; i++) {
+        this.transport.setRequestHeader(headerNames[i], headers[headerNames[i]]);
     }
 
-    for (var name in headers)
-      this.transport.setRequestHeader(name, headers[name]);
   },
 
   success: function() {
@@ -1901,18 +1915,6 @@
     return window[klass];
   }
 
-  if (F.ElementExtensions) {
-    copy(Element.Methods, HTMLElement.prototype);
-    copy(Element.Methods.Simulated, HTMLElement.prototype, true);
-  }
-
-  if (F.SpecificElementExtensions) {
-    for (var tag in Element.Methods.ByTag) {
-      var klass = findDOMClass(tag);
-      if (typeof klass == "undefined") continue;
-      copy(T[tag], klass.prototype);
-    }
-  }
 
   Object.extend(Element, Element.Methods);
   delete Element.ByTag;
@@ -3274,4 +3276,4 @@
   }
 }
 
-Element.addMethods();
\ No newline at end of file
+Element.addMethods();


More information about the Jifty-commit mailing list