Ok have watched all lectures and sections and etc, read the book, I am thoroughly following all instructions for this course and uptill now walkthroughs and etc have helped me a lot but at pset6 im completely at lost, the entire specs have gone over my head and I am beginning to think that english is not my language may be im having problems due to this in understanding the pset. I think I have understood what they are asking of me in lookup, but after that I am completely lost....can someone explain to me in easy English as to what am I expected to do and what should I b doing in pset6
For this exercise, think of the internet as two moving parts. A client that sends a request (for pset6 that will be browser or curl) and a server (which you will write) which responds to that request. You could think of it like the functions in pset5. speller (client) sends a word to dictionary/check (server), evaluates it (is it in the dictionary?) and sends back a response (true or false) to speller, who then reports on it.
server first verifies the request is valid (
parse), then sends the result of that request back (
load) to the client. The client needs to know the type of result it is getting back, is it a picture? is it textual? so that info is sent, too (
All servers, (eg apache, IIS) usually allow you to define a default "home page". That's what
lookup is fairly straight forward. Function will receive a path, evaluate it, and send back a "response". (Within server,
lookup is processed after
parse. I suspect it is the first exercise in the pset because it is the easiest). Path will be something like "/cat.jpg" or "/hello.php", basically the abs_path result of your parse function. If it would help to get a visual, add printfs to the beginning of the functions to see what the incoming data looks like.
parse has a lot of rules to verify. The
request-line, described in the spec as
method SP request-target SP HTTP-version CRLF will be what
line contains. It would look something like
GET /hello.php?name=a HTTP/1.1\r\n. Basically you need to break it up into "parts" and do the appropriate validations.
load is similar to
recover from pset4. You are reading a file (sent as an arugment) but instead of writing the data to another file on disk, you are storing that data in "dynamically allocated memory". This is the "result" that will be sent back to client. Reviewing some of the earlier course material about pointers and dynamic memory allocation may help. This function is (to my mind) the most difficult.
indexes. You are sent a path. You need to determine if the files index.php or index.html exist in that path. (hint:
This pset really challenges one's understanding of scope and pointers and memory allocation and learning to use new functions; coalescing everything learned thus far. It can never be said that it's easy.