Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Start a free Courses trial
to watch this video
There are many times in which HTTP is used to send a request whose purpose is to modify data on the server. POST requests are used for this purpose and are constructed a bit differently than GET requests that send data. In a POST request, data is sent in the request payload instead of in the URI. This video shows you exactly how this is accomplished.
UTF-8 Encoding
The UTF-8 character encoding is one in which every character in the Unicode Character Set can be represented with anywhere from 1 to 4 bytes.
In general, the character encoding of a submitted form is UTF-8 by default. In the video, all the characters that were part of the payload can be represented with 1 byte (8 bits). This is because they're all part of the Basic Latin Characters. See for yourself by looking at the Basic Latin Characters and finding all the ones from our POST request payload in the list:
firstname=Chris&language=English
Since each character in that payload will take up exactly one byte, counting the bytes is equivalent to counting the characters.
What happens if you use a character outside of Basic Latin? For example, consider the scenario that your payload instead looks like this:
greeksigma=Σ
The Greek capital sigma cannot be represented with one byte (it actually takes two). What your browser will do upon submitting a form with a Σ
is substitute a URL-encoded version, which in the case of the Greek capital sigma is %CE%A3
. So, the HTTP POST payload becomes the following:
greeksigma=%CE%A3
Therefore, when the content-length header is calculated with this URL-encoded version, it has a value of 17, which is what will be included in the HTTP POST request.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up