Top Banner
Understanding the Web through HTTP Olivia Brundage
58

Understanding the Web through HTTP

Jan 22, 2017

Download

Internet

Olivia Brundage
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Understanding the Web through HTTP

Understanding the Web through HTTP

Olivia Brundage

Page 2: Understanding the Web through HTTP

Agenda

• Overall Flow of Data

• How HTTP Requests Work

• Introduction to HTTPS

Page 3: Understanding the Web through HTTP

Meet Datum!

He’s just a baby now, but let’s see how he grows into a big data through the OSI (Open System Interconnection) model.

Page 4: Understanding the Web through HTTP

Physical Layer

Datum’s home town.

He communicates with everyone through a physical medium (like wires).

His language is bits (0’s and 1’s).

Page 5: Understanding the Web through HTTP

Trailer

Data Link Layer

To talk to neighbors, Datum’s bits gets encapsulated as a frame so that the receiver know the start and end of the message.

This layer provides node-to-node data transfer.Header DATA

1010 101001000100111Bit pattern that

specifies the start of the frame

Bit pattern that specifies the end of

the frame

Frame

Page 6: Understanding the Web through HTTP

Network Layer

In order to reach the outside world, Datum has to be transformed into a packet.

Routers are responsible directing data to the correct machine.

This is where you’ll find IP addresses.

IP

Page 7: Understanding the Web through HTTP

Transport Layer

To reach his destination, Datum must be transported via a segment or datagram.

Segments are sent through the Transmission Control Protocol (TCP), which is for a connection-oriented transmission.

Datagrams are sent through the User Datagram Protocol (UDP), which is for a connectionless transmission (e.g., streaming).

IP

Page 8: Understanding the Web through HTTP

Session Layer

Upon arriving at his destination, Datum must create an open session to the client, so that they can continue their business.

Once here, Datum evolves into his final form: Data.

IP

Page 9: Understanding the Web through HTTP

Presentation Layer

Datum is now on the full screen!

This layer takes all your backend code, CSS files, etc and delivers them to the final layer.

IP

Page 10: Understanding the Web through HTTP

Application Layer

This layer is the end-user product and contains high-level APIs like resource sharing and remote file access.

This is also the layer you develop in!

IP

Page 11: Understanding the Web through HTTP

What’s with this abstraction?

• Gives us a framework on how data transforms throughout the network.

• But it’s a little too specific; real networks are a lot muddier than this.

Page 12: Understanding the Web through HTTP

OSI vs TCP/IP

TCP/IP combines some layers of the OSI, making it more succinct to the messier way of real life.

Page 13: Understanding the Web through HTTP

Where does HTTP fit into this?

Page 14: Understanding the Web through HTTP

First, let’s go over what HTTP is

• HTTP stands for hyper-text transfer protocol.

• This protocol is in plain-text and is stateless.

• This protocol resides in the application layer.

Page 15: Understanding the Web through HTTP

Let’s break down these requests!

Page 16: Understanding the Web through HTTP

Make the Request!

You type the URL (Uniform Resource Locator) in the browser:

http://www.google.com

Page 17: Understanding the Web through HTTP

Hey, wait! What’s an URL?

http://www.domain.com:1234/path/to/resource?a=b&x=yprotocol

host

port

resource path

query

Page 18: Understanding the Web through HTTP

Now, time to get the IP address!

After you type the address, another application layer protocol is used to get the IP address: the Domain Name System (DNS)

What’s the IP to Google’s server?

Google’s IP is 65.246.5.22

Domain Name Server Web Browser

Page 19: Understanding the Web through HTTP

HTTP makes the Request Racket

Page 20: Understanding the Web through HTTP

Generic Structure of HTTP Requests

message = <start-line> *(<message-header>) CRLF # Carriage Return Line Feed (i.e., new line) [<message-body>]

• Start line contains the initial request

• Message headers give more details about the request you’re making (i.e., the host, how to maintain the connection, how to handle cookies, etc).

NB: GET requests do not contain a message body, but POST requests can.

Page 21: Understanding the Web through HTTP

tl/dr:

A simple request looks likes:

VERB RESOURCE-URL PROTOCOLMESSAGE-HEADERS

GET / HTTP/1.1 HOST: www.google.comCONNECTION: keep-alive

Page 22: Understanding the Web through HTTP

HTTP Main Verbs

• GET: fetches a resource determined by the URL

• The server sends the resource in the message body if the status code is 200

• POST: creates a new resource where the requests specifies the data needed for the resource

• Params are carried in the body of the request instead of the header; making this a more ‘secure’ type of request

• PUT: updates a resource

• DELETE: deletes a resource

NB: PUT and DELETE can be considered a specialized versions of POST

Page 23: Understanding the Web through HTTP

Lesser-known Verbs

• HEAD: Requests only the server headers. Primarily used for checking if the resource has changed via timestamps.

• TRACE: Retrieves the hops that a request takes to round trip the serve. Used for network diagnostic purposes.

• OPTIONS: Retrieves the server capabilities. For the client-side, it can be used to modify the request based on what the server can support.

Page 24: Understanding the Web through HTTP

HTTP Packet gets ready for Transportation!

HTTP RequestHTTP Packet

TCP Packet

The TCP information maintains the session. Now to the IP layer!

TCP

Page 25: Understanding the Web through HTTP

TCP now hands it over to the Internet Protocol

• Local/Sender Address: Your PC’s IP • Receiver Address: Google’s Server IP • Post Service Nodes: Routers

Page 26: Understanding the Web through HTTP

HTTP RequestIP

IP further encapsulates the data

TCP

TCP

IP Packet

Now we head over to the last layer!

Page 27: Understanding the Web through HTTP

TrailerHTTP RequestHeader

The Network Interface Layer makes the Ethernet frame.

IP TCP

IP Packet

Ethernet Frame

We can finally send this HTTP request out!

Page 28: Understanding the Web through HTTP

The HTTP request is out!

Page 29: Understanding the Web through HTTP

So let’s recap.

Page 30: Understanding the Web through HTTP

But there’s still more to HTTP!!

Page 31: Understanding the Web through HTTP

Some important notes about the response:

• The server will send the status code along with the message payload.

• The status code tells the client how to interpret the server response.

Page 32: Understanding the Web through HTTP
Page 33: Understanding the Web through HTTP

1xx: Informational Messages

• This is just a provisional code and provides informational messages like:

• Keep this connection alive (i.e., still sending information)

• Tell the client to continue sending it’s message

• Ignore the next response

• This class was introduces in HTTP/1.1. Version 1.0 ignores this message.

Page 34: Understanding the Web through HTTP

2xx: Successful

Your request made it!

Page 35: Understanding the Web through HTTP

Request was completely successful.

Page 36: Understanding the Web through HTTP

Message successful, but there was no message body

Page 37: Understanding the Web through HTTP

3xx: Redirection

Your request needs to directed elsewhere.

Page 38: Understanding the Web through HTTP

Resource has moved to a new URL.

Page 39: Understanding the Web through HTTP

Resource has not been modified since last request.

Page 40: Understanding the Web through HTTP

4xx: Client Error

When the server thinks the client made a bad request.

Page 41: Understanding the Web through HTTP

Request can’t be fulfilled due to bad syntax.

Page 42: Understanding the Web through HTTP

Specifically used when authentication has failed.

Page 43: Understanding the Web through HTTP

Request was valid, but the server won’t respond.

Page 44: Understanding the Web through HTTP

Resource can’t be found. Try again later?

Page 45: Understanding the Web through HTTP

Method isn’t supported (like using a GET on a form that requires a POST method)

Page 46: Understanding the Web through HTTP

5xx: Server Error

Server failed creating the request

Page 47: Understanding the Web through HTTP

The infamous, generic server error.

Page 48: Understanding the Web through HTTP

The server doesn’t recognize the request method or can’t fulfill it.

Page 49: Understanding the Web through HTTP

The server was acting as a proxy and received something bad from the upstream server.

Page 50: Understanding the Web through HTTP

The server was acting as a proxy and did not receive a timely response from the upstream server.

Page 51: Understanding the Web through HTTP

Want more status codes?Here’s your source: https://httpstatusdogs.com/

Page 52: Understanding the Web through HTTP

Overall HTTP Interaction

Page 53: Understanding the Web through HTTP

So where does HTTPS come into play?

That is: HTTP over TLS, HTTP over SSL, and HTTP Secure

Page 54: Understanding the Web through HTTP

What HTTPS Is

• HTTPS provides authentication to the website and protection of the privacy and integrity of the exchanged data

• Security is brought to you by the Secure Sockets Layer (SSL) or the improved Transport Layer Security (TLS).

• Encryption is brought to you by Public Key Encryption and Symmetric Key Encryption.

• This security component happens between HTTP request and TCP (before they connect).

Page 55: Understanding the Web through HTTP

HTTPS Happens Before the Connection is Made

Page 56: Understanding the Web through HTTP

How HTTPS Works

• Client/Server Hellos

• Authenticate Client and Server with Cryptography

• Generate session keys

• Further interactions will be based on the encrypted session keys

Page 57: Understanding the Web through HTTP

Questions?

Page 58: Understanding the Web through HTTP

Resources

• “What is the role of the OSI layers when making a request to a website?” https://www.quora.com/What-is-the-role-of-OSI-layers-when-we-open-a-webpage

• “HTTP: The Protocol Every Web Developer Must Know - Part 1"https://code.tutsplus.com/tutorials/http-the-protocol-every-web-developer-must-know-part-1--net-31177

• “HTTP: The Protocol Every Web Developer Must Know - Part 2"https://code.tutsplus.com/tutorials/http-the-protocol-every-web-developer-must-know-part-2--net-31155

• "Understanding HTTP Basics"http://learn.onemonth.com/understanding-http-basics