CSC361 Tutorial 3
CSC361 Tutorial 3
Copyright By PowCoder代写 加微信 powcoder
Marking Breakdown
Test Scenarios
Design Check
Marking Breakdown
● 200 ok 1 pt
● Persistent connection 1pt
● Correct return large file 1pt
● 404 not found 1pt
● 400 bad request 2 pts
● Multiple clients 1 pt
● Timeout 1 pt
● Back-to-back request 1pt
● Server output format 1pt
Test Scenario 1
● 200 ok test
○ Small file request
○ Test whether 200 ok responded correctly 1pt
○ Test the format of server output 1pt
○ Large file request, if return content correctly 1pt
Test Scenario 2
● 404 test
○ Non-existing file request
○ Test whether 404 responded correctly 1pt
Test Scenario 3
● 400 bad request test
○ Test whether 400 bad request responded correctly 2pt
Test Scenario 4
● Multi-client test
○ On h1 send a persistent connection, and on r send another 1pt
Test Scenario 5
● Persistent and timeout test
○ On h1 send a persistent connection, then send another request without connection header 1pt
○ On h1 send a persistent connection, then wait for timeout 1pt
Test Scenario 6
● Back-to-back test
○ On h1 send requests from a text file 1pt
● To test your server whether this feature is enabled, you can create a text
file (call test.txt) as follows:
GET /notfound HTTP/1.0
Connection:keep-alive
GET /hello.html HTTP/1.0
Connection:keep-alive
get /hello.html http/1.0
Connection:keep-alive
GET /notfound HTTP/1.0
Connection:keep-alive
● nc ip_address port < test.txt Demo 1: Line by line Requests use nc connect to sws, and input requests and headers line by line Demo 2: Back-to-back requests Send multiple requests at the same time: Common Problems 1. Server output log format 2. Fail to respond to bad request immediately (do not need to wait for the new 3. Cannot support line by line and back-to-back requests simultaneously 4. HTTP Headers 5. Close the connection when a. No keep-alive headers in the request b. Bad requests c. timeout 6. Extra new line returned after the end of the file content, which is not correct server_address = ('localhost', 80) server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server.setblocking(0) server.bind(server_address) You should not hardcode the ip address and port number if not is_match: response_messages[s] += "HTTP/1.0 400 Bad Request" response_messages[s] += "HTTP/1.0 200 OK" Be sure to consider the case of 404 not found Do not forget to add “\r\n” for the response line # keep-alive is false, close the connection if (connection_alive == None): print("closing connection...") close_socket(sock, inputs, outputs,message_queues) Remember to remove any unnecessary prints before submission. CSC361 Tutorial 3 Marking Breakdown Test Scenario 1 Test Scenario 2 Test Scenario 3 Test Scenario 4 Test Scenario 5 Test Scenario 6 Slide Number 9 Demo 1: Line by line Requests Demo 2: Back-to-back requests Common Problems Slide Number 13 Slide Number 14 Slide Number 15 程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com