Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
- Introduction to HTTP 1:22
- Building a Case for HTTP 2:41
- Intro to HTTP 2 questions
- HTTP Requests Using Telnet 7:08
- HTTP Request Format 3:01
- HTTP Headers 1 question
- HTTP Response Format 3:42
- HTTP Response Format 1 question
- Sending Data with a GET Request 4:11
- Sending Data with a GET Request 1 question
- Sending Data with a POST Request 5:57
- Sending Data with a POST Request 1 question

- 2x 2x
- 1.75x 1.75x
- 1.5x 1.5x
- 1.25x 1.25x
- 1.1x 1.1x
- 1x 1x
- 0.75x 0.75x
- 0.5x 0.5x
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 up-
Olivier Van hamme
5,418 Points1 Answer
-
Edgar Isai Salgado Cortez
4,048 Points1 Answer
-
PLUS
Douglas Benson
Courses Plus Student 2,490 Points1 Answer
-
Mert Kahraman
12,118 Points2 Answers
-
Julie Pham
12,290 PointsHow can I count the number bytes of data that I will pass in the POST request?
Posted by Julie PhamJulie Pham
12,290 Points4 Answers
View all discussions for this video
Related 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