Nhu Nguyen b199045f10 update readme to be more clear | 6 년 전 | |
---|---|---|
src | 6 년 전 | |
.gitignore | 6 년 전 | |
README.md | 6 년 전 | |
pom.xml | 6 년 전 |
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 so when I go to http://localhost:5000/hello
, I will see world
as the response/form?key=value
path so when I go to http://localhost:5000/form?key=value
I will see the value as the 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 so when I go to http://localhost:5000/404
I will see the Are you lost?
message with a 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 so when I go to http://localhost:5000/redirect
I will be redirect to http://google.com
Currently 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:5000
http://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]