Skip to content

Commit

Permalink
Update prototype.js to [5985], fixes content-type issue with simulate…
Browse files Browse the repository at this point in the history
…d HTTP methods

git-svn-id: http://svn-commit.rubyonrails.org/rails/branches/1-2-pre-release@5987 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
madrobby committed Jan 18, 2007
1 parent 3ec808e commit 03e763f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
17 changes: 9 additions & 8 deletions actionpack/lib/action_view/helpers/javascripts/prototype.js
Expand Up @@ -833,25 +833,26 @@ Ajax.Request.prototype = Object.extend(new Ajax.Base(), {

request: function(url) {
this.url = url;
var params = this.options.parameters, method = this.options.method;
this.method = this.options.method;
var params = this.options.parameters;

if (!['get', 'post'].include(method)) {
if (!['get', 'post'].include(this.method)) {
// simulate other verbs over post
params['_method'] = method;
method = 'post';
params['_method'] = this.method;
this.method = 'post';
}

params = Hash.toQueryString(params);
if (params && /Konqueror|Safari|KHTML/.test(navigator.userAgent)) params += '&_='

// when GET, append parameters to URL
if (method == 'get' && params)
if (this.method == 'get' && params)
this.url += (this.url.indexOf('?') > -1 ? '&' : '?') + params;

try {
Ajax.Responders.dispatch('onCreate', this, this.transport);

this.transport.open(method.toUpperCase(), this.url,
this.transport.open(this.method.toUpperCase(), this.url,
this.options.asynchronous);

if (this.options.asynchronous)
Expand All @@ -860,7 +861,7 @@ Ajax.Request.prototype = Object.extend(new Ajax.Base(), {
this.transport.onreadystatechange = this.onStateChange.bind(this);
this.setRequestHeaders();

var body = method == 'post' ? (this.options.postBody || params) : null;
var body = this.method == 'post' ? (this.options.postBody || params) : null;

this.transport.send(body);

Expand All @@ -887,7 +888,7 @@ Ajax.Request.prototype = Object.extend(new Ajax.Base(), {
'Accept': 'text/javascript, text/html, application/xml, text/xml, */*'
};

if (this.options.method == 'post') {
if (this.method == 'post') {
headers['Content-type'] = this.options.contentType +
(this.options.encoding ? '; charset=' + this.options.encoding : '');

Expand Down
17 changes: 9 additions & 8 deletions railties/html/javascripts/prototype.js
Expand Up @@ -833,25 +833,26 @@ Ajax.Request.prototype = Object.extend(new Ajax.Base(), {

request: function(url) {
this.url = url;
var params = this.options.parameters, method = this.options.method;
this.method = this.options.method;
var params = this.options.parameters;

if (!['get', 'post'].include(method)) {
if (!['get', 'post'].include(this.method)) {
// simulate other verbs over post
params['_method'] = method;
method = 'post';
params['_method'] = this.method;
this.method = 'post';
}

params = Hash.toQueryString(params);
if (params && /Konqueror|Safari|KHTML/.test(navigator.userAgent)) params += '&_='

// when GET, append parameters to URL
if (method == 'get' && params)
if (this.method == 'get' && params)
this.url += (this.url.indexOf('?') > -1 ? '&' : '?') + params;

try {
Ajax.Responders.dispatch('onCreate', this, this.transport);

this.transport.open(method.toUpperCase(), this.url,
this.transport.open(this.method.toUpperCase(), this.url,
this.options.asynchronous);

if (this.options.asynchronous)
Expand All @@ -860,7 +861,7 @@ Ajax.Request.prototype = Object.extend(new Ajax.Base(), {
this.transport.onreadystatechange = this.onStateChange.bind(this);
this.setRequestHeaders();

var body = method == 'post' ? (this.options.postBody || params) : null;
var body = this.method == 'post' ? (this.options.postBody || params) : null;

this.transport.send(body);

Expand All @@ -887,7 +888,7 @@ Ajax.Request.prototype = Object.extend(new Ajax.Base(), {
'Accept': 'text/javascript, text/html, application/xml, text/xml, */*'
};

if (this.options.method == 'post') {
if (this.method == 'post') {
headers['Content-type'] = this.options.contentType +
(this.options.encoding ? '; charset=' + this.options.encoding : '');

Expand Down

0 comments on commit 03e763f

Please sign in to comment.