<aside> 💡

Below are a few more explanations on the function requirements

</aside>

vector<char>

A vector<char> is handy for receiving data in your web proxy. It has a .data() which gives you access to the underlying array. You can just pass &v.data()[index] as the pointer for receive() to start writing into, and write straight in the vector (of course tell it how much space there is). If you need more space... you can just grow the vector. Then call receive again at the end index that hasn't been filled up yet. (And remember that receive tells you how many bytes it read, so you'll know how much has been filled up.

CONNECT

  1. When you get a CONNECT request, you need to send a 200 OK to the client after you setup the connection to the server. Otherwise the client does not know you are ready for it to communicate with the server.
  2. steps your proxy should take for CONNECT:

Payload of HTTP response

Here is a tip I think is worth passing along on reading the RFCs.  Parsing and interpreting HTTP requests and responses appropriately is one of the major tasks in this project, which means you need to read RFC a lot to understand different formats of request and response messages and all those delimiters that tell you when a section should end. For example, the payload of an HTTP response may be returned via different formats.

You may see fields like these in your HTTP header:

Transfer-Encoding: chunked

In contrast to the common header field you see:

Content-Length: <length>

You may want to handle these two formats differently, and you may find it confusing in the RFCs on understanding the format of message:

chunked-body   = *chunk
                      last-chunk
                      trailer-part
                      CRLF

     chunk          = chunk-size [ chunk-ext ] CRLF
                      chunk-data CRLF
     chunk-size     = 1*HEXDIG
     last-chunk     = 1*("0") [ chunk-ext ] CRLF

     chunk-data     = 1*OCTET ; a sequence of chunk-size octets

To understand the meaning of symbols, go take a look at RFC5234