COSC 6377 : Computer Networks

Spring 2019

MW 4-530pm at AH 2

Homework 1: HTTP Client

Due: 2/20/2019

In this homework, we will write an HTTP client that communicates with a distant web service, fetches temperature and image content as JSON and saves the received image as a file.

The web service is provided under http://ruby.cs.uh.edu:5000/homework1. A successful GET request will return a JSON data in the following format:

	{
	  temperature: temp_value_as_int
	  encoding: enc_value_as_string
	  Image: image_as_string
	}
      

There will be two types of encoding returned by the service “base64” and “z85”.

You can just load the URL in a browser to get a sense of what the response looks like.

Write an HTTP client "client.py". The client opens a socket to the remote server ruby.cs.uh.edu. It sends an HTTP GET request to the server. The client then receives the JSON data, parses it and extracts the specified fields (feel free to use the JSON library in Python). The client read the image string, decodes it according to the encoding format that was specified, then saves the image to a file "image.bmp" in BMP format and the temperature in text format to a file "temperature.txt".

Please Do not use any HTTP libraries for the communication with the server. You should implement a simplified HTTP protocol directly on top of the socket. Feel free to use Python libraries to parse the JSON data and decode the image format. You don’t have to implement base64 or z85 decoding algorithms.

How to run the program?

python client.py

Your program should be written in Python3 and must run on program.cs.uh.edu.

Submission

Please upload your code using git invitation for hw1. Please include a README that describes the author, contact information, a short description of the software, and finally limitations of your implementation. Include any interesting observations, measurement results, etc. in your README.