|
|
8 vuotta sitten | |
|---|---|---|
| src | 8 vuotta sitten | |
| .gitignore | 8 vuotta sitten | |
| README.md | 8 vuotta sitten | |
| pom.xml | 8 vuotta sitten |
The training wheels are coming off....sort of. In this lab, I set up the basic server for you. Your task is to handle other type of responses. You can refactor the code however you see fit and I highly advise you to do so.
Read the wiki page HTTP and figure out how to write the response for each of the request. I wrote a sample one for you to see. In src/main/java/Main.java, run the main method. Once the server is up, go http://localhost:5000, note it says Hello world.
Your task for this lab is to read the HTTP and figure out how to generate the proper response. Remember to write unit test.
I will not answer the following questions:
If you come to me, I will show you LMGTFY(Let me google that for you). I will answer anything related to why your code doesn't work. I will also answer design related questions. I will also help you construct the test if you know what message you want to write.
/hello path which will return world as a response/form?key=value path which will return the value as a response. For example if I call /form?search=blue, the server will return blue. If I call /form?color=red, the server will return red. The response code should be 201./404 path which will Are you lost? with 404 response code./form?key=value path so it will only response if it is a POST request. Any other type of request will a 404 response./redirect path which will redirect you to http://google.comCurrently our server can handle one request at a time. This is called Synchronous. We want multiple users to access the server at the same time. This is called Asynchronous. Read up on the term here.
run method of the RequestHandler, add Thread.sleep(5000); before the try and catch to make your server go to sleep for 5s before processing your request.
http://localhost:5000http://localhost:5000/files/[image_name] (e.g. /files/high5.gif) will show the image/files path. The files path will list out all the files in the src/main/resources folder in a list.long id and String name/users path to display all the users name in a list./users/1 to show information for the first user (their name and id)/users/new path to show a form where user can enter a name to create a new user./users with a POST method to accept the form information and create the user. Redirect to /users/[user_id]