

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Still calibrating
click for more info
Not enough gems
Cost: 6 gems
1: Welcome to 'Learn the HTTP Protocol'
incomplete
2: TheStartup™
incomplete
3: 8 Bytes
incomplete
4: Newlines
incomplete
5: Channel Refactor
incomplete
This lesson's interactive features are locked, please to keep using them
Reading 8 bytes at a time is a good start, but 8 byte chunks aren't how people tend to communicate... you probably noticed that it was hard to read the individual messages through your program.
Trust me, this all leads up to HTTP. I promise.
Let's update our code to continue to read 8 bytes at a time, but now let's format the output line by line. It should now print the data in the same format:
read: %s\n
But now %s represents an entire line of the input file. We're decoupling how we present and parse (full lines) the data from how we read it (8 bytes at a time).
Here's what I did:
read: LINE
Where LINE is the "current line" we've aggregated so far plus the current "part". Then reset the "current line" variable to an empty string. Note that if we only have one "part", we don't need to print, as we have not reached a new line yet.
Run and submit the CLI tests.