
What should you be doing right now?

Recommended schedule

Many ways to implement client/server communication
We will use HTTP (protocol that drives the Web)
Server will implement Web API
Clients will use HTTP reqeust/response protocol to send requests
	to the server, and get back responses from the server
	
Implementing a Web API Server

Of course, HTTP was originally invented to support web browsing.
But, it can also be used to implement server's that have Web APIs.

Web browsing with HTTP
	Click on link causes HTTP "GET" request to fetch requested document from web server
	Form submit causes HTTP "POST" that sends form data to server, which returns document in response-body

The HTTP network protocol can also be used to implement Web APIs
	Web API Server provides "methods" that clients can call
	APIs include two basic types of operations: accessors and mutators
		In HTTP, accessor operations are implemented using GET requests, and
		mutators are implemented using POST reqeusts (or PUT, DELETE, etc.)

HTTP Network Protocol

URLs

Requests
	GET REQUESTS:
	
	GET request has the following format:
		GET <url-path> <http-version>
		<header-name>: <header-value>
		<header-name>: <header-value>
		<header-name>: <header-value>
		...
	
	EXAMPLE:
	
	GET /games/list HTTP/1.1
	Authorization: afj232hj2332
	Accept: application/json
	
	POST REQUESTS:
	
	POST request has the following format:
		POST <url-path> <http-version>
		<header-name>: <header-value>
		<header-name>: <header-value>
		<header-name>: <header-value>
		...

		<request-body>
	
	EXAMPLE:
	
	POST /routes/claim HTTP/1.1
	Authorization: afj232hj2332
	Content-Type: application/json

	{
		"route": "atlanta-miami" 
	}
	
Responses
	HTTP responses have the following format:
	
	<http-version> <status-code> <reason-phrase>
	<header-name>: <header-value>
	<header-name>: <header-value>
	<header-name>: <header-value>
	...
	
	<response-body>
	
	EXAMPLE:
	
	HTTP/1.1 200 OK
	Content-Type: application/json
	Content-Length: 226
	
	{ "game-list": [
			{ "name": "fhe game", "player-count": 3, ... },
			{ "name": "work game", "player-count": 4, ... },
			{ "name": "church game", "player-count": 2, ... }
		]
	}

Implementing a Web API with HttpServer

Calling a Web API with HttpURLConnection


	
