Skip to content

tdyer/ga-http-quiz

Repository files navigation

HTTP Protocol

Language of the Internet
  • We will look at from a developers perspective. A solid understanding will allow you to understand and debug web applications.

Resources

Are HTML pages, images, videos, javascript, css, etc.

Resource Addresses, Uniform Resource Location (URL)

Embedded Resources

Some resources, like an HTML page, may have embedded links (URLs). The browser will load these embedded resources after as it loads the containing page. 
For example, a HTML page may have links to images, videos, javascript, etc that will be *also* be loaded by the browser.

Network Stack

Each layer represents a Protocol.

  • These Protocols are defined by Request For Comment (RFC) documents. No need to dig into these now.
  • We are going to focus on the HTTP protocol. Network Protocol

HTTP Request/Response

HTTP Clients
* Browser. Chrome, Firefox, Safari, IE, …	
* Command line utilities. curl, wget
* HTTP Ruby libraries. HTTParty, Faraday, Typhoues, ...
HTTP Servers. Web Servers.
* Apache, Nginx, Thin, Tomcat, Pow, …

HTTP Request

From a HTTP client,typically a browser, to a web server running on a host system. 
* HTTP Request Methods
	GET and POST most used.
	* GET. Retrieve a resource.
	* POST. Create a resource.
	* PUT. Update a resource.
	* DELETE, Delete a resource.
	* HEAD, Retreive the headers for a resource. 
* GET HTTP Request Format
	[method] [URL] [version]
	[headers]
* Example GET Request:
	GET http://vermonster.com HTTP/1.1
	Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
	Accept-Encoding:gzip,deflate,sdch
	Accept-Language:en-US,en;q=0.8
	Connection:keep-alive
	Host:vermonster.com
	User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_5)
	AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1659.2 Safari/537.36#### 
	
	* Media Types
		What kind of resource can we retrieve? Defined by Multipurpose Internet Mail Extensions (MIME) standards. Used in the HTTP Request Accept Header and the HTTP Response Content-Type Header.
		* HTML = text/html
	  	* GIF Image = image/gif
	  	* PNG Image = image/gif
	  	* MP4 Video = video/mp4
	  	* PDF = application/pdf
	  	* JSON = application/json

See Media Types*

HTTP Response

Reply to a HTTP client from a web server.
* HTTP Response Overview
[version] [status] [reason]
[headers]

[body]	# typically HTML, json, ...
* HTTP version should be 1.1
* Status Codes, [Status Codes](http://en.wikipedia.org/wiki/List_of_HTTP_status_codes)
	* 200  OK 
	* 301 Moved Permanently 
	* 302 Moved Temporarily 
	* 400 Bad Request   
	* 403 Forbidden 
	* 404 Not Found 
	* 500 Internal Server Error

Viewing HTTP Request/Response

* curl. Command line apps that sends requests.
	* curl -i http://www.vermonster.com/
* Chrome Inspector. Developer tool built into Chrome browser.
	* View -> Developer -> Developer Tools 
	* Select Network
	* Cmd-R to send request
* Run a *very* simple Rack application.
	* ruby simple_rack_app.rb
	* In Chrome: 
		* http://localhost:1234/
	* Look at in Chrome Inspector, Cmd-Option i.
	* Go to the Network tab and refresh, Cmd-R
	* Notice the HTTP parameter seen by the web server.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors