[Proto-Scripty] Re: How is the MIME boundary set with HTML5 FormData and Ajax.Request()?

2016-07-18 Thread Adam Nielsen

>
> How can I get the contentType set to include the MIME boundary used by the 
> HTML5 FormData object?
>

I've done a little more investigating, and if I make this change to 
prototype.js then it fixes the problem:

diff --git a/js/prototype.js b/js/prototype.js
index cc89daf..70e2e58 100644
--- a/js/prototype.js
+++ b/js/prototype.js
@@ -1762,8 +1762,6 @@ Ajax.Request = Class.create(Ajax.Base, {
 };
 
 if (this.method == 'post') {
-  headers['Content-type'] = this.options.contentType +
-(this.options.encoding ? '; charset=' + this.options.encoding : ''
);
 
   /* Force "Connection: close" for older Mozilla browsers to work
* around a bug where XMLHttpRequest sends an incorrect


Is there any way to tell Prototype to leave the HTTP Content-Type unset?  
It looks like jQuery handles this by having contentType set to false, but I 
can't see how Prototype handles it.

Thanks,
Adam.

-- 
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to prototype-scriptaculous+unsubscr...@googlegroups.com.
To post to this group, send email to prototype-scriptaculous@googlegroups.com.
Visit this group at https://groups.google.com/group/prototype-scriptaculous.
For more options, visit https://groups.google.com/d/optout.


[Proto-Scripty] How is the MIME boundary set with HTML5 FormData and Ajax.Request()?

2016-07-18 Thread Adam Nielsen
Hi all,

I am struggling a bit to get a HTML5 FormData object submitting with 
Prototype's Ajax.Request().

Because the form data needs to be submitted as multipart/form-data, I need 
to set the Content-Type to include the MIME boundary, otherwise the 
receiving end can't decode the multipart/form-data content.

I am doing something like this:

var d = new FormData();
d.append('name', $F('name'));
d.append('type', 'blah');
d.append('filecontent', $('file').files[0]);

new Ajax.Request('url', {
method: 'post',
//contentType: 'multipart/form-data', // need MIME boundary
postBody: d,
onSuccess: function(r) { }
});

If I leave out the contentType parameter, then the form gets submitted as 
application/x-www-form-urlencoded, but the content is in 
multipart/form-data so it is not possible to decode it.  If I set the 
contentType to multipart/form-data then the recipient complains that the 
MIME boundary is missing from the HTTP Content-Type header.

How can I get the contentType set to include the MIME boundary used by the 
HTML5 FormData object?

Many thanks,
Adam.

-- 
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to prototype-scriptaculous+unsubscr...@googlegroups.com.
To post to this group, send email to prototype-scriptaculous@googlegroups.com.
Visit this group at https://groups.google.com/group/prototype-scriptaculous.
For more options, visit https://groups.google.com/d/optout.