Advertisement
Guest User

turninwithit_hw

a guest
Oct 17th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. this program connects to sockets in a server and receives requests, reading in if it is a GET or PUT.
  2. If it is not it breaks. If you send a GET it will grab the file name and check for that file, if that file
  3. exists, it will parse the contents and send them. If it is a PUT, it receives content and saves it into a
  4. file. The Client will check if there are enough args, if not, it will tell the user they need more in their
  5. input, if it is enough, they will then parse those args and save them as variables. It will use these variables
  6. to grab all the necessary information and see what kind of request it is. If it's a GET, it grabs the required
  7. filename, and attempts a GET to the server. If it is a PUT, it parses a file by that name, and sends the results to
  8. the server. If the file doesn't exist, it lets the user know this.
  9.  
  10. Some testing:
  11.  
  12. working GET:
  13.  
  14. ➜ alex python client.py localhost 8888 GET sent.txt
  15. 200 ok test
  16. ('Received', "'200 ok test'")
  17.  
  18.  
  19. wrong filename GET:
  20.  
  21. ➜ alex python client.py localhost 8888 GET doesnt_exist.txt
  22. 404 not found
  23. ('Received', "'404 not found'")
  24.  
  25. working put:
  26. ➜ alex python client.py localhost 8888 PUT sent.txt
  27.  
  28. success
  29.  
  30. wrong filename put:
  31. ➜ alex python client.py localhost 8888 PUT doesnt_exist.txt
  32.  
  33. no such file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement