How does content-type work in java?

2

I saw a video of a guy using the

connection.setRequestProperty("content-type", "aplication/x-www-urlencoded");

But I did not understand how it works, especially "aplication/x-www-urlencoded" .

    
asked by anonymous 07.10.2017 / 03:35

1 answer

3

Content-Type is an HTTP Header that identifies the data structure that will be sent / received from the server, and is language independent.

In this case: Content-Type: application / x-www-urlencoded means that the structure of the data sent / received is a query key string = value separated by &

Ex:

nome=John&sobrenome=Doe

Another example: Content-Type: application / json means that the data will be sent / received following the JSON structure:

{ "nome": "John", "sobrenome": "Doe"}

More on: link

    
07.10.2017 / 04:18