SlideShare uma empresa Scribd logo
1 de 44
Baixar para ler offline
Communicating
on the Web

This talk at: http://joind.in/10392
About Me
● Developer at ServerGrove
● All around nerd
● Systems Administrator for
7 years
● @aramonc in all the places
CAN’T COMMUNICATE
WELL WITHOUT
COMMON GROUND
HYPERTEXT
TRANSFER PROTOCOL
●
●
●
●

Designed side by side with HTML
Before were the bulletin boards
Question & Answer style 2 way communication
M2M communication method composed of text
documents
THE CLIENT
The client is any application that initiates
an HTTP communication
THE SERVER
Servers are any application that receives a request
and terminates with a response
HTTP IS STATELESS
STATELESS IS THE
OPPOSITE OF
STATEFUL
● Stateless, in this context, is short term memory
● Stateless communication allows for
○ distributed system
○ load balancing
○ manage state separately
● Makes caching more difficult
● Makes real time apps more difficult
● Application is responsible for preserving state
SHORT/LONG POLLING
● Used to update client side application state in
“real time” applications
● Usually initiated by JavaScript
● Can be initiated by any client side technology
like Objective C.
● Short polling initiates short lived connections
to check if state changed
● Long polling initiates long lived connections
until state changes
THE REQUEST
GET https://www.google.com/ HTTP/1.1
:version: HTTP/1.1
:method: GET
:scheme: https
:host: www.google.com
user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_5)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.57
Safari/537.36
accept-encoding: gzip,deflate,sdch
accept-language: en-US,en;q=0.8,es-419;q=0.6,es;q=0.4
accept: text/html,application/xhtml+xml,
application/xml;q=0.9,image/webp,*/*;q=0.8
cookie: OGP=-3904011:; HSID=A0hmwhHriSEJzPSI;
SSID=AKHSzv76RXaggJwJ;
APISID=PXmCmOabqgrdcm_z/A7eIE7i4enNC0Hn0;
THE REQUEST
● Human readable text document
● Composed of the request, a set of headers, and
an optional content body
● Headers are key value pairs separated by a colon
& terminated by a new line
● Headers describe the request and offer additional
metadata
THE REQUEST LINE
GET https://www.google.com/ HTTP/1.1
● The request is the first line of the document
● Composed of 3 parts
● From the right: HTTP version
○ Let’s the server know which headers it can
expect
THE REQUEST
GET https://www.google.com/ HTTP/1.1
http://server/path/?query=string
●
●
●
●

URL (Universal Resource Locator)
Every request is for a resource
Like interacting with a bank teller
Composed of the scheme, the host, the path,
and optionally a query string
THE REQUEST
GET https://www.google.com/ HTTP/1.1
● A verb indicating what you would like to do with
the resource
● Withdraw money, create a new account, deposit
money, or even rob the bank
COMMON METHODS
GET, POST, PUT, DELETE
HEAD, OPTIONS
●
●
●
●
●

Also called verbs
Describe the intent of the request
CRUD is most common
Small subset
Some, like patch, still in draft form
COMMON HEADERS
user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X
10_8_5) AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/31.0.1650.57 Safari/537.36
●
●
●
●

Describes the client
Set by the client
Can be changed programmatically
Mozilla/5.0 compatible hold over from
Netscape years
COMMON HEADERS
accept-encoding: gzip,deflate,sdch
accept-language: en-US,en;q=0.8,es-419;
q=0.6,es;q=0.4
accept-charset: utf-8
accept: text/html,application/xhtml+xml,
application/xml;q=0.9,image/webp,*/*;q=0.8
ACCEPT FAMILY
● Describes the type of content the client can
understand
● accept headers is a list of MIME types
● ;q= indicates preference level
COMMON MIME TYPES
●
●
●
●
●
●
●

text/html
text/css
text/javascript
text/xml
text/plain
application/json
application/rss+xml

●
●
●
●
●
●
●

multipart/form-data
image/jpeg
image/gif
image/png
audio/mpeg
video/mpeg
video/x-flv
COMMON HEADERS
cookie: SSID=AKHSzv76RXaggJwJ;
● Describes the contents of a cookie file set by
a previous connection to the same host
● Used to persist data across HTTP
connections
● Stored in files locally or in memory in the
client process
NOT SO COMMON
authorization: Basic QWpIlc2FtZQ==
● Describes login credentials to password
protected URLs
● Two methods, Basic and Digest
● Digest more secure, but more complicated to
set up
● If not included, response is to request a set of
credentials
● Best if used in combination with TLS/SSL
NOT SO COMMON
x-hello: world
hello: world
●
●
●
●
●

x- used to describe a custom header
Deprecated by one of the latest RFCs
Still used by some APIs
New form is not to use the xFuture proof
REQUEST BODY
Content-Type: multipart/form-data; boundary=AaB03x
--AaB03x
Content-Disposition: form-data;
name="submit-name"
Larry
--AaB03x
Content-Disposition: form-data; name="files";
filename="file1.txt" Content-Type: text/plain
... contents of file1.txt ...
--AaB03x--
REQUEST BODY
● Optional content for POST, PUT, etc requests
● Typically used to send data from HTML forms
● Form data formatted as key value pairs with no
boundary
● Multipart is most complicated
● Form data is separated by boundaries &
terminated by the boundary plus -● File uploads need to be done with multipart
● Content-Type is a MIME type describing the
contents of the file
● Could be base64 representation of binary data
THE RESPONSE
HTTP/1.1 200 OK
status: 200 OK
version: HTTP/1.1
content-encoding: gzip
content-type: text/html; charset=UTF-8
date: Wed, 20 Nov 2013 01:48:58 GMT
set-cookie: PREF=ID=26af7b02617ef537:U=9bc26b9e4;
expires=Fri, 20-Nov-2015 01:48:58 GMT; path=/;
domain=.google.com
COMMON HEADERS
content-encoding: gzip
content-type: text/html;
charset=UTF-8
● The content body can be anything from binary, to
json, to html
● The content returned is described by the contenttype & content enconding
● Related to the accept-header
COMMON HEADERS
set-cookie:
PREF=ID=26af7b02617ef537:
U=9bc26b9e4; expires=Fri, 20-Nov2015 01:48:58 GMT; path=/;
domain=.google.com
●
●
●
●
●

Sets or overrides a cookie in the client’s system
Cookie content
Optional expiration date
Path & Domain cookie applies to
Localhost is not a valid domain. When testing it’s
preferable not to set the domain
THE RESPONSE
HTTP/1.1 200 OK
● Only thing required to be sent back
● Sometimes the only thing sent back
● Apache always sends back all the SHOULD
headers
STATUS CODES
200 OK, 404 NOT FOUND,
500 INTERNAL SERVER ERROR
STATUS CODE FAMILIES
●
●
●
●
●

1xx: Informational Messages
2xx: Success Messages
3xx: Redirection Messages
4xx: Client Error
5xx: Server Error

● Specific codes convey specific messages
● Sometimes sending the status code is enough
to communicate a message
1XX STATUS CODES
● 100 CONTINUE
● 101 SWITCHING PROTOCOL
● Not very common
● Perfect for use with polling techniques for
asynchronous tasks
2XX STATUS CODES
● 201 CREATED
● 202 ACCEPTED
3XX STATUS CODES
●
●
●
●

301 MOVED PERMANENTLY
302 FOUND
304 NOT MODIFIED
305 USE PROXY
4XX STATUS CODES
●
●
●
●

401 NOT AUTHORIZED
402 PAYMENT REQUIRED
403 FORBIDDEN
429 TOO MANY REQUESTS
5XX STATUS CODES
● 501 NOT IMPLEMENTED
● 502 BAD GATEWAY
● 503 SERVICE UNAVAILABLE
NOT JUST STANDARD
418 & 420
● 418 is I AM A TEAPOT, IETF April Fool’s
Joke
● 420 used by Twitter for a while to indicate too
many connections
WHY DOES ANY
OF IT MATTER?
FORMS
● POST request are marginally more secure,
but not really
● Requests that carry content can carry more
content on the body than on the query string
● Forms can send both query strings and
content
● Can submit forms through
XMLHTTPRequests with extra headers
BETTER SECURITY
● Use of Auth headers
● Use of custom headers
○ Server can reply with CSRF Tokens
○ Client can send OAuth Tokens
● Still not as secure as using SSL, but better than
nothing at all.
APIs
● Not just about HyperMedia, all is
important
● Well documented
● URLs that point to actual resources
● Use of Request methods & Headers
● Use of proper Response codes
● Standard communication without
vendor sponsorship
WHAT WE LEFT OUT
●
●
●
●

Caching
Proxies
Load balancing
TLS
THE FUTURE
● New RFCs and specifications
○ Patch method
○ New status codes
○ HTTP 2.0
● SPDY
○ Experimental protocol for a faster web
○ Pronounced speedy
○ Implementation before standardization
○ claims of 64% page load reduction over
HTTP in lab tests
○ Many concurrent connections over one TCP
channel
RESOURCES
●
●
●
●
●
●
●
●
●

http://net.tutsplus.com/tutorials/tools-and-tips/http-theprotocol-every-web-developer-must-know-part-1/
http://net.tutsplus.com/sessions/http-succinctly/
http://en.wikipedia.
org/wiki/List_of_HTTP_status_codes#1xx_Informational
http://en.wikipedia.org/wiki/Internet_media_type
http://www.nczonline.net/blog/2009/05/05/http-cookiesexplained/
http://www.chromium.org/spdy/spdy-whitepaper
http://http2.github.io/
http://xkcd.com/869/
http://blog.servergrove.com/2013/12/16/talking-http/
THANK YOU
http://joind.in/10392

Mais conteúdo relacionado

Mais procurados

NATS in action - A Real time Microservices Architecture handled by NATS
NATS in action - A Real time Microservices Architecture handled by NATSNATS in action - A Real time Microservices Architecture handled by NATS
NATS in action - A Real time Microservices Architecture handled by NATS
Raül Pérez
 

Mais procurados (20)

JUG louvain websockets
JUG louvain websocketsJUG louvain websockets
JUG louvain websockets
 
Introducing HTTP/2
Introducing HTTP/2Introducing HTTP/2
Introducing HTTP/2
 
SPDY and HTTP/2
SPDY and HTTP/2SPDY and HTTP/2
SPDY and HTTP/2
 
Generating Unified APIs with Protocol Buffers and gRPC
Generating Unified APIs with Protocol Buffers and gRPCGenerating Unified APIs with Protocol Buffers and gRPC
Generating Unified APIs with Protocol Buffers and gRPC
 
A New Internet? Introduction to HTTP/2, QUIC and DOH
A New Internet? Introduction to HTTP/2, QUIC and DOHA New Internet? Introduction to HTTP/2, QUIC and DOH
A New Internet? Introduction to HTTP/2, QUIC and DOH
 
Basics of NGINX
Basics of NGINXBasics of NGINX
Basics of NGINX
 
Firewall and NAT Fundamentals - pfSense Hangout January 2014
Firewall and NAT Fundamentals - pfSense Hangout January 2014Firewall and NAT Fundamentals - pfSense Hangout January 2014
Firewall and NAT Fundamentals - pfSense Hangout January 2014
 
NATS in action - A Real time Microservices Architecture handled by NATS
NATS in action - A Real time Microservices Architecture handled by NATSNATS in action - A Real time Microservices Architecture handled by NATS
NATS in action - A Real time Microservices Architecture handled by NATS
 
Grpc present
Grpc presentGrpc present
Grpc present
 
gRPC and Microservices
gRPC and MicroservicesgRPC and Microservices
gRPC and Microservices
 
HTTP2 & HPACK #pyfes 2013-11-30
HTTP2 & HPACK #pyfes 2013-11-30HTTP2 & HPACK #pyfes 2013-11-30
HTTP2 & HPACK #pyfes 2013-11-30
 
In a HTTP/2 World - DeccanRubyConf 2017
In a HTTP/2 World - DeccanRubyConf 2017In a HTTP/2 World - DeccanRubyConf 2017
In a HTTP/2 World - DeccanRubyConf 2017
 
Go-ing a long way with Rails
Go-ing a long way with RailsGo-ing a long way with Rails
Go-ing a long way with Rails
 
What HTTP/2.0 Will Do For You
What HTTP/2.0 Will Do For YouWhat HTTP/2.0 Will Do For You
What HTTP/2.0 Will Do For You
 
Micro HTTP Server Implemented in C @ COSCUP 2016
Micro HTTP Server Implemented in C @ COSCUP 2016Micro HTTP Server Implemented in C @ COSCUP 2016
Micro HTTP Server Implemented in C @ COSCUP 2016
 
HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era
HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 eraHTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era
HTTP/2 and QUICK protocols. Optimizing the Web stack for HTTP/2 era
 
GeoDistributed datacenter: the DNS way
GeoDistributed datacenter: the DNS wayGeoDistributed datacenter: the DNS way
GeoDistributed datacenter: the DNS way
 
Power-up services with gRPC
Power-up services with gRPCPower-up services with gRPC
Power-up services with gRPC
 
Build a Micro HTTP Server for Embedded System
Build a Micro HTTP Server for Embedded SystemBuild a Micro HTTP Server for Embedded System
Build a Micro HTTP Server for Embedded System
 
REST vs gRPC: Battle of API's
REST vs gRPC: Battle of API'sREST vs gRPC: Battle of API's
REST vs gRPC: Battle of API's
 

Semelhante a Communicating on the web

computer network introduction. psc notes . Assisant professor in cse.
computer network introduction. psc notes . Assisant professor in cse.computer network introduction. psc notes . Assisant professor in cse.
computer network introduction. psc notes . Assisant professor in cse.
bushraphd2022
 
CN 6131(15) Module IV.docx
CN 6131(15) Module IV.docxCN 6131(15) Module IV.docx
CN 6131(15) Module IV.docx
AkhilMS30
 
The OpenID Connect Protocol
The OpenID Connect ProtocolThe OpenID Connect Protocol
The OpenID Connect Protocol
Clément OUDOT
 

Semelhante a Communicating on the web (20)

HTTP
HTTPHTTP
HTTP
 
computer network introduction. psc notes . Assisant professor in cse.
computer network introduction. psc notes . Assisant professor in cse.computer network introduction. psc notes . Assisant professor in cse.
computer network introduction. psc notes . Assisant professor in cse.
 
Http/2
Http/2Http/2
Http/2
 
Design Web Service API by HungerStation
Design Web Service API by HungerStationDesign Web Service API by HungerStation
Design Web Service API by HungerStation
 
21 HTTP Protocol #burningkeyboards
21 HTTP Protocol #burningkeyboards21 HTTP Protocol #burningkeyboards
21 HTTP Protocol #burningkeyboards
 
API
APIAPI
API
 
Introduction To Web (Mukesh Patel)
Introduction To Web (Mukesh Patel)Introduction To Web (Mukesh Patel)
Introduction To Web (Mukesh Patel)
 
The new (is it really ) api stack
The new (is it really ) api stackThe new (is it really ) api stack
The new (is it really ) api stack
 
HyperText Transfer Protocol (HTTP)
HyperText Transfer Protocol (HTTP)HyperText Transfer Protocol (HTTP)
HyperText Transfer Protocol (HTTP)
 
Hypertexttransferprotocolhttp 131012171813-phpapp02
Hypertexttransferprotocolhttp 131012171813-phpapp02Hypertexttransferprotocolhttp 131012171813-phpapp02
Hypertexttransferprotocolhttp 131012171813-phpapp02
 
WebCamp 2016: Python. Вячеслав Каковский: Real-time мессенджер на Python. Осо...
WebCamp 2016: Python. Вячеслав Каковский: Real-time мессенджер на Python. Осо...WebCamp 2016: Python. Вячеслав Каковский: Real-time мессенджер на Python. Осо...
WebCamp 2016: Python. Вячеслав Каковский: Real-time мессенджер на Python. Осо...
 
Introduction to Web Application Security - Blackhoodie US 2018
Introduction to Web Application Security - Blackhoodie US 2018Introduction to Web Application Security - Blackhoodie US 2018
Introduction to Web Application Security - Blackhoodie US 2018
 
Basic web architecture
Basic web architectureBasic web architecture
Basic web architecture
 
HTTP In-depth
HTTP In-depthHTTP In-depth
HTTP In-depth
 
Application layer protocols
Application layer protocolsApplication layer protocols
Application layer protocols
 
CN 6131(15) Module IV.docx
CN 6131(15) Module IV.docxCN 6131(15) Module IV.docx
CN 6131(15) Module IV.docx
 
CN 6131(15) Module IV.pdf
CN 6131(15) Module IV.pdfCN 6131(15) Module IV.pdf
CN 6131(15) Module IV.pdf
 
The OpenID Connect Protocol
The OpenID Connect ProtocolThe OpenID Connect Protocol
The OpenID Connect Protocol
 
WebCamp Ukraine 2016: Instant messenger with Python. Back-end development
WebCamp Ukraine 2016: Instant messenger with Python. Back-end developmentWebCamp Ukraine 2016: Instant messenger with Python. Back-end development
WebCamp Ukraine 2016: Instant messenger with Python. Back-end development
 
Micro HTTP Server for Embedded
Micro HTTP Server for EmbeddedMicro HTTP Server for Embedded
Micro HTTP Server for Embedded
 

Último

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Último (20)

Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 

Communicating on the web