Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

application/x-www-form-urlencoded and charset="utf-8"?

Is it customary to omit ;charset="utf-8" when the Content-type is application/x-www-form-urlencoded?

In particular, when using accept-charset="utf-8" in a form tag, I would expect some indication that utf-8 is being used in the headers, but I'm not seeing any.

Here is my simple test in Chrome. The form page is:

<html> <head> <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/> </head> <body> <form method="POST" action="printenv.cgi" accept-charset="utf-8"> Your name: <input name="name" type="text" size="30"> </form> </body> </html> 

And the headers for the generated request are:

POST /printenv.cgi HTTP/1.1 Host: ...:8000 Connection: keep-alive Content-Length: 19 Cache-Control: max-age=0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Origin: http://...:8000 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.94 Safari/537.36 Content-Type: application/x-www-form-urlencoded Referer: http://...:8000/utf8-test.html Accept-Encoding: gzip,deflate,sdch Accept-Language: en-US,en;q=0.8 

What's the convention for specifying how the form parameter values are encoded?

like image 938
ErikR Avatar asked May 29 '13 16:05

ErikR


People also ask

What is the meaning of application X www form Urlencoded?

The application/x-www-form-urlencoded content type describes form data that is sent in a single block in the HTTP message body. Unlike the query part of the URL in a GET request, the length of the data is unrestricted.

How do you send data in application X www form Urlencoded?

To use it, we need to select the x-www-form-urlencoded tab in the body of their request. We need to enter the key-value pairs for sending the request body to the server, and Postman will encode the desired data before sending it. Postman encodes both the key and the value.

Which annotations access application X www form Urlencoded parameters?

Now notice, we have used @ModelAttribute above to map the incoming application/x-www-form-urlencoded or multipart/form-data directly to the Student model class. The @ModelAttribute is an annotation that binds a method parameter or method return value to a named model attribute and then exposes it to a web view.

What is the use of charset UTF-8 in HTML?

Definition and Usage The charset attribute specifies the character encoding for the HTML document. The HTML5 specification encourages web developers to use the UTF-8 character set, which covers almost all of the characters and symbols in the world!


1 Answers

  1. There is no charset parameter defined for this media type.

  2. For the encoding guidelines, see https://url.spec.whatwg.org/#application/x-www-form-urlencoded .

The application/x-www-form-urlencoded standard implies UTF-8 and percent-encoding.

Though:

A legacy server-oriented implementation might have to support encodings other than UTF-8 as well as have special logic for tuples of which the name is _charset. Such logic is not described here as only UTF-8 is conforming.

like image 140
Julian Reschke Avatar answered Sep 21 '22 14:09

Julian Reschke