Presentation is loading. Please wait.

Presentation is loading. Please wait.

Uniform Resource Locators (URLs)

Similar presentations


Presentation on theme: "Uniform Resource Locators (URLs)"— Presentation transcript:

1 Uniform Resource Locators (URLs)
Scheme Port Number Query Host Name Hierarchical portion CS 190 Lecture Notes: Tweeter Project

2 CS 190 Lecture Notes: Tweeter Project
HTTP GET Request Method URL Protocol Version GET /statuses/user_timeline?my_id=100 HTTP/1.1 Host: User-Agent: Mozilla/5.0 Accept: text/html, */* Accept-Language: en-us Accept-Charset: ISO ,utf-8 Connection: keep-alive blank line Headers Body (empty) CS 190 Lecture Notes: Tweeter Project

3 CS 190 Lecture Notes: Tweeter Project
HTTP Response Version Status Status Message HTTP/ OK Date: Thu, 24 Jul :36:27 GMT Server: Tweeter/1.0 Content-Type: application/json;charset=UTF-8 Content-Length: 266 blank line {"tweets": [{"id": 20006, "user": 100, "time": "Mon Oct 27 18:02:57 PDT 2014", "text": "I’m at home now",}, {"id": 20005, "user": 100, "time": "Mon Oct 27 17:33:57 PDT 2014", "text": "Stuck in traffic"} ] } Headers Body CS 190 Lecture Notes: Tweeter Project

4 CS 190 Lecture Notes: Tweeter Project
HTTP POST Request Method URL Protocol Version POST /statuses/update HTTP/1.1 Host: User-Agent: Mozilla/5.0 Accept: text/html, */* Accept-Language: en-us Accept-Charset: ISO ,utf-8 Connection: keep-alive blank line my_id=100&status=Stuck%20in%20traffic Headers Body (form data) Parameters CS 190 Lecture Notes: Tweeter Project

5 CS 190 Lecture Notes: Tweeter Project
Example Requests POST /friendships/create?my_id=100&user_id=200 User 100 becomes a follower of user 200 POST /friendships/destroy?my_id=100&user_id=200 User 100 is no longer a follower of user 200 GET /friends/ids.json?user_id=100 Return ids for all users that user 100 is following: [100, 84, 290, 16] POST /statuses/update?my_id=100&status=Sleepy Create a new tweet for user 100 CS 190 Lecture Notes: Tweeter Project

6 CS 190 Lecture Notes: Tweeter Project
Network APIs serverSocket = new ServerSocket(portNumber); Open a socket for server to accept connections Containing application provides the port number socket = serverSocket.accept(); reader = new InputStreamReader( socket.getInputStream()); Wait for next incoming connection socket.close() Close specific connection to client All socket calls can throw IOException CS 190 Lecture Notes: Tweeter Project


Download ppt "Uniform Resource Locators (URLs)"

Similar presentations


Ads by Google