Set content type to utf-8 using angularjs $ http

I upload a form with files, text, etc. in appobine blobstore:

$http({
    method: 'POST',
    url: the_url,
    transformRequest: formDataObject,
    data: event,
    headers: {'Content-Type': undefined}
})

The request is sent successfully with the follwing header:

Content-Type:multipart/form-data; boundary=----WebKitFormBoundaryYeRxOO7y3qHNWd83

When I try to set the content type to "multipart/form-data;charset=UTF-8", I lose the border and get an error in the response:Bad content type. Please use multipart.

What is the correct way to add UTF-8 encoding?

+4
source share
3 answers

According to RFC 1341:

As stated in the definition of the Content-Transfer-Encoding field, no encoding other than "7bit", "8bit", or "binary" is permitted for entities of type "multipart". The multipart delimiters and header fields are always 7-bit ASCII in any case, and data within the body parts can be encoded on a part-by-part basis, with Content-Transfer-Encoding fields for each appropriate body part.

Therefore, in this case you should use Content-Transfer-Encodinginstead Content-Type.

+4
source

My decision should not change anything:

It turns out the use headers: {'Content-Type': undefined}was correct. Now everything works (and I just changed the backend).

, webob , , . webob . , , , webob , webob, app.yaml:

libraries:
- name: webob
  version: "1.2.3"
+3

​​ : Content-Type: /-; = ---- WebKitFormBoundaryYeRxOO7y3qHNWd83; = UTF-8

0

All Articles