=============[ Checking if a name is available ]============= http://cs65.cs.dartmouth.edu/nametest.pl accepts GET requests for 'name'. E.g.: http://cs65.cs.dartmouth.edu/nametest.pl?name=tim It responds with a JSON object specifying if the name is available: E.g.: {"avail":"true","name":"tim"} or {"avail":"false","name":"sergey"} If your GET requests does not contain the parameter 'name', you will get an error: E.g.: http://cs65.cs.dartmouth.edu/nametest.pl?nave=tom gets {"error":"GET request must contain parameter 'name'"} =============[ Saving a profile ]============= http://cs65.cs.dartmouth.edu/profile.pl accepts POST requests to create profiles. A valid request's body must be valid JSON and must contain key parameters "name" and "password". There is, so far, no restriction on other parameters. E.g., the body of {"name":"tim","password":"1234","likes":"cats,sweets","id":"1001"} is valid. The first time a valid POST request arrives for a name that is available _at that moment_, a record will be created for that name. When subsequent syntactically valid POST requests arrive for the same name, they will only be accepted if the password member in them matches the password already stored for that name. If that is the case, the new record will completely replace the old record. (You may notice that you cannot change passwords with this protocol. We will implement an additional protocol for changing passwords.) The server responds to successful submissions (new or with matching passwords) with JSON objects that contain "status" equal to "OK" and an echoed-back copy of your accepted input. E.g., [newline injected for readability]: {"status":"OK", "data":"{\"name\":\"tim\",\"password\":\"1234\",\"id\":\"1003\"}"} Deviations from this protocol should get you responses with JSON objects with "status" of "ERROR", a "data" member that provides a clarification, and a copy of your erroneous input. For example [newlines inserted for readability]: { "status":"ERROR", "input":"{\"name\":\"tom\",\"password\"=\"1234\",\"id\"=\"1002\"}", "data":"decode_json failed, invalid JSON. error: ':' expected, at character offset 24 (before \"=\"1234\",\"id\"=\"1002\"}...\") at /var/www/html/profile.pl line 80.\n\n"} [in this example, I typed '=' instead of JSON's correct separator ':'] NOTE: Since these are POST requests, no parameters in the URL are accepted (unlike GET, which, by contrast, has no body, and passes all of its parameters in the URL). =============[ Retrieving a profile ]============= http://cs65.cs.dartmouth.edu/profile.pl accepts GET requests to retrieve already created profiles. The URL line must contain parameters 'name' and 'password', the former matching some record previously created with POST as above, the latter matching the saved password of that record. The response to a correct name/password pair is the JSON record saved previously with a POST under that name and password. E.g., http://cs65.cs.dartmouth.edu/profile.pl?name=tim&password=1234 gives you {"name":"tim","password":"1234","likes":"cats,sweets","id":"1001"} Deviations from this protocol give you JSON objects representing errors, e.g., {"error":"GET request must contain parameter 'name'"} {"error":"GET request must contain parameter 'password'"} {"error":"No record for name '@#$%^&' found"} {"error":"Password doesn't match stored password"} IMPORTANT: If you get back a java.io.IOException for a valid URL, this may indicate a bug in my code. Please contact me ASAP so that I could fix it! A Wireshark capture of the transaction so faulting would get you 2 extra credit points. See https://stackoverflow.com/questions/2794006/java-io-filenotfoundexception-for-valid-url for why it works this way.