You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by js...@apache.org on 2010/12/24 05:35:47 UTC

svn commit: r1052444 - /tuscany/sca-cpp/trunk/modules/js/htdocs/component.js

Author: jsdelfino
Date: Fri Dec 24 04:35:47 2010
New Revision: 1052444

URL: http://svn.apache.org/viewvc?rev=1052444&view=rev
Log:
Fix content types. Removed duplicate function.

Modified:
    tuscany/sca-cpp/trunk/modules/js/htdocs/component.js

Modified: tuscany/sca-cpp/trunk/modules/js/htdocs/component.js
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/js/htdocs/component.js?rev=1052444&r1=1052443&r2=1052444&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/js/htdocs/component.js (original)
+++ tuscany/sca-cpp/trunk/modules/js/htdocs/component.js Fri Dec 24 04:35:47 2010
@@ -307,11 +307,7 @@ HTTPBindingClient.prototype._sendRequest
 
     /* Send the request */
     http.open("POST", this.uri, (req.cb != null));
-
-    /* setRequestHeader is missing in Opera 8 Beta */
-    try {
-        http.setRequestHeader("Content-type", "text/plain");
-    } catch(e) {}
+    http.setRequestHeader("Content-type", "application/json-rpc");
 
     /* Construct call back if we have one */
     if(req.cb) {
@@ -442,7 +438,7 @@ HTTPBindingClient.getHTTPRequest = funct
 
 
 HTTPBindingClient.prototype.get = function(id, responseFunction) {
-    var xhr = this.createXMLHttpRequest();
+    var xhr = HTTPBindingClient.getHTTPRequest();
     xhr.onreadystatechange = function() {
         if (xhr.readyState == 4) {
             if (xhr.status == 200) {
@@ -462,7 +458,7 @@ HTTPBindingClient.prototype.get = functi
 };
 
 HTTPBindingClient.prototype.post = function (entry, responseFunction) {
-    var xhr = this.createXMLHttpRequest();
+    var xhr = HTTPBindingClient.getHTTPRequest();
     xhr.onreadystatechange = function() {
         if (xhr.readyState == 4) {
             if (xhr.status == 201) {
@@ -478,12 +474,12 @@ HTTPBindingClient.prototype.post = funct
         }
     }
     xhr.open("POST", this.uri, true);
-    xhr.setRequestHeader("Content-Type", "application/atom+xml");
+    xhr.setRequestHeader("Content-Type", "application/atom+xml;type=entry");
     xhr.send(entry);
 };
 
 HTTPBindingClient.prototype.put = function (id, entry, responseFunction) {
-    var xhr = this.createXMLHttpRequest();
+    var xhr = HTTPBindingClient.getHTTPRequest();
     xhr.onreadystatechange = function() {
         if (xhr.readyState == 4) {
             if (xhr.status == 200) {
@@ -499,12 +495,12 @@ HTTPBindingClient.prototype.put = functi
         }
     }
     xhr.open("PUT", this.uri + '/' + id, true);
-    xhr.setRequestHeader("Content-Type", "application/atom+xml");
+    xhr.setRequestHeader("Content-Type", "application/atom+xml;type=entry");
     xhr.send(entry);
 };
 
 HTTPBindingClient.prototype.del = function (id, responseFunction) {       
-    var xhr = this.createXMLHttpRequest();
+    var xhr = HTTPBindingClient.getHTTPRequest();
     xhr.onreadystatechange = function() {
         if (xhr.readyState == 4) {
             if (xhr.status == 200) {
@@ -518,18 +514,6 @@ HTTPBindingClient.prototype.del = functi
     xhr.send(null);
 };
 
-HTTPBindingClient.prototype.createXMLHttpRequest = function () {
-    /* Mozilla XMLHttpRequest */
-    try { return new XMLHttpRequest(); } catch(e) {}      
-    
-    /* Microsoft MSXML ActiveX */
-    for (var i = 0; i < HTTPBindingClient.msxmlNames.length; i++) {
-        try { return new ActiveXObject(HTTPBindingClient.msxmlNames[i]); } catch (e) {}
-    }
-    alert("XML http request not supported");
-    return null;
-};
-
 /**
  * Public API.
  */