Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Protocolo HTTP
Search
Gilson Filho
June 06, 2017
Programming
0
550
Protocolo HTTP
Apresentação para o mini-curso de protocolo HTTP ministrado na Faculdade Evangélica de Brasília
Gilson Filho
June 06, 2017
Tweet
Share
More Decks by Gilson Filho
See All by Gilson Filho
Como monitorar os erros da sua aplicação com o Sentry
gilsondev
0
2.1k
Airflow - Automatizando seu fluxo de trabalho
gilsondev
1
1.3k
Airflow: Data Workflow Management
gilsondev
0
470
Workshop Docker
gilsondev
0
430
Django: framework web para perfeccionistas com prazos
gilsondev
0
430
Django - Framework para perfeccionistas em prazos
gilsondev
0
47
Vim - Um editor onipresente e flexível
gilsondev
2
470
Vim - Um editor onipresente e flexível
gilsondev
2
130
Desenvolvendo aplicações web com python e web2py
gilsondev
0
600
Other Decks in Programming
See All in Programming
CSC509 Lecture 06
javiergs
PRO
0
250
Swift Concurrency - 状態監視の罠
objectiveaudio
2
480
どの様にAIエージェントと 協業すべきだったのか?
takefumiyoshii
2
620
Conquering Massive Traffic Spikes in Ruby Applications with Pitchfork
riseshia
0
150
SpecKitでどこまでできる? コストはどれくらい?
leveragestech
0
600
Serena MCPのすすめ
wadakatu
4
910
XP, Testing and ninja testing ZOZ5
m_seki
3
350
Go言語の特性を活かした公式MCP SDKの設計
hond0413
1
200
Domain-centric? Why Hexagonal, Onion, and Clean Architecture Are Answers to the Wrong Question
olivergierke
1
500
Local Peer-to-Peer APIはどのように使われていくのか?
hal_spidernight
2
460
フロントエンド開発に役立つクライアントプログラム共通のノウハウ / Universal client-side programming best practices for frontend development
nrslib
7
3.9k
Building, Deploying, and Monitoring Ruby Web Applications with Falcon (Kaigi on Rails 2025)
ioquatix
2
680
Featured
See All Featured
BBQ
matthewcrist
89
9.8k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.2k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
610
Java REST API Framework Comparison - PWX 2021
mraible
33
8.8k
The Art of Programming - Codeland 2020
erikaheidi
56
14k
Making the Leap to Tech Lead
cromwellryan
135
9.5k
Large-scale JavaScript Application Architecture
addyosmani
514
110k
Site-Speed That Sticks
csswizardry
11
880
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
15
1.7k
Keith and Marios Guide to Fast Websites
keithpitt
411
22k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
285
14k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Transcript
PROTOCOLO
COMO NOS COMUNICAMOS?
None
COMO ENTENDER O QUE ESTÁ SENDO COMUNICADO?
asdlkj) (*KJH*&HGF% &ḦGhgf ?
AMBOS PRECISAM USAR O MESMO TIPO DE COMUNICAÇÃO
Olá! Tudo bem? Estou bem Obrigado!
HTTP HYPERTEXT TRANSFER PROTOCOL
“ Um utilizado para sistemas de informação de , distribuídos
e colaborativos. Ele é a base para a comunicação de dados da . protocolo de comunicação hipermídia World Wide Web Fonte: Wikipedia
Um protocolo de comunicação por hipertexto usando arquitetura cliente/servidor
Hipertexto é um texto que agrega outras informações como outros
textos, imagens, etc.
Usado para comunicação entre navegadores e servidores
No caso da web ele é representado por um .
hiperlink
TODA COMUNICAÇÃO NO HTTP É POR MEIO DE MENSAGENS
Quero a página do Google CLIENTE ENVIA A MENSAGEM
Entendi. Tome a página SERVIDOR RECEBE A MENSAGEM E RESPONDE
Requisição é o que o cliente envia para o servidor
Resposta é o que o servidor envia ao cliente
None
None
HTTP É STATELESS
None
Quando faz uma requisição você solicita um recurso
URI UNIVERSAL RESOURCE IDENTIFIER
Não é URL que você quis dizer?
Não é URL que você quis dizer? Não, é URI
mesmo?
URI = URL + URN URL = Universal Resource Locator
URN = Universal Resource Name
None
HTTP ESTRUTURA DAS MENSAGENS
REQUISIÇÃO
RESPOSTA
None
HEADERS INFORMACOES DA MENSAGEM
ACESSANDO O GOOGLE curl -v http://google.com
* Connected to google.com (200.175.224.80) port 80 (#0) GET /
HTTP/1.1 Host: google.com User-Agent: curl/7.47.1 Accept: */*
HTTP/1.1 302 Found Cache-Control: private Content-Type: text/html; charset=UTF-8 Location: http://www.google.com.br/?gfe_rd=cr&ei=DZnaV9TcIMmm8wf22o3ABA
Content-Length: 262 Date: Thu, 15 Sep 2016 12:50:21 GMT <HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8"> <TITLE>302 Moved</TITLE></HEAD><BODY> <H1>302 Moved</H1> The document has moved <A HREF="http://www.google.com.br/?gfe_rd=cr&ei=DZnaV9TcIMmm8wf22o3ABA">here</A>. </BODY></HTML>
Existem headers para uso na requisição e na resposta
http://bit.ly/1B1ZAdN Request Headers
http://bit.ly/1yySXwu Response Headers
HEADERS CUSTOMIZADOS NÃO PRECISA SE LIMITAR AOS PADRÕES
* Connected to google.com.br (191.33.177.34) port 80 GET / HTTP/1.1
Host: google.com.br User-Agent: curl/7.47.1 Accept: */*
HTTP/1.1 301 Moved Permanently Location: http://www.google.com.br/ Content-Type: text/html; charset=UTF-8 Date:
Thu, 15 Sep 2016 12:59:12 GMT Expires: Sat, 15 Oct 2016 12:59:12 GMT Cache-Control: public, max-age=2592000 Server: gws Content-Length: 222 X-XSS-Protection: 1; mode=block X-Frame-Options: SAMEORIGIN // Corpo da resposta
Headers precedidos de X são customizados
HTTP/1.1 301 Moved Permanently // Outros headers... X-XSS-Protection: 1; mode=block
X-Frame-Options: SAMEORIGIN
HTTP/1.1 200 OK Location: http://exemplo.com Content-Type: text/html; charset=UTF-8 Content-Length: 67
X-Server-Version: 1.0.0 <h1>Corpo HTML da mensagem</h1>
Por ser fora do padrão, usem com responsabilidade nas suas
aplicações
http://bit.ly/1B235Rh Siga a errata dos custom headers
HTTP MÉTODOS
GET POST DELETE PUT TRACE HEAD OPTIONS CONNECT
GET POST DELETE PUT
GET SOLICITA UM RECURSO
GET / HTTP/1.1 Host: google.com User-Agent: curl/7.47.1 Accept: */*
POST ENVIA DADOS PARA CRIAR RECURSO
POST /httptutorial/methods HTTP/1.1 User-Agent: curl/7.30.0 Host: localhost:8080 Accept: */* If-modified-since:
Tue, 07 May 2014 18:12:00 GMT Content-Type: application/x-www-form-urlencoded Content-Length: 41 Nome=Carlos&Idade=28&Curso=Administracao
PUT ATUALIZA O RECURSO SOLICITADO
PUT /httptutorial/methods/12 HTTP/1.1 User-Agent: curl/7.30.0 Host: localhost:8080 Accept: */* If-modified-since:
Tue, 07 May 2014 18:12:00 GMT Content-Type: application/x-www-form-urlencoded Content-Length: 41 Nome=Carlos&Idade=28&Curso=Administracao
DELETE REMOVE O RECURSO SOLICITADO
DELETE /httptutorial/methods/12 HTTP/1.1 User-Agent: curl/7.30.0 Host: localhost:8080 Accept: */*
http://bit.ly/1ugUXbc Explicação resumida sobre os métodos
HTTP STATUS CODE
HTTP/1.1 200 OK Server: Apache-Coyote/1.1 Content-Length: 28 Date: Tue, 02
Dec 2014 19:17:21 GMT <h1>Request Recebido!</h1>
HTTP/1.1 200 OK
HTTP/1.1 200 OK Status Code
HTTP/1.1 200 OK Rease Phrase
Status Code 00 OK 2 O primeiro dígito define uma
classe de resposta
Existem cinco classes
Indica uma resposta provisória 1xx - Informativa http://bit.ly/1D3FggM
Indica que a ação solicita foi aceita e processada pelo
servidor 2xx - Sucesso http://bit.ly/1wWZC85
Indica que a ação deve ser levado ao cliente 3xx
- Redirecionamento http://bit.ly/12npUmx
Indica que ocorreu um erro na ação do cliente 4xx
- Erro do Cliente http://bit.ly/1Ga6JeZ
Indica outros tipos de erros encontrados no servidor 5xx -
Outros erros http://bit.ly/1Ga6JeZ
STATUS CODE CÓDIGOS DE STATUS MAIS CONHECIDOS
None
None
None
None
None
None
None
None
None
None
None
None
HTTP COOKIES
São dados enviados pelo website para o browser do cliente
no momento do seu acesso.
None
None
Chave Valor
VAMOS VER TUDO ISSO NA PRÁTICA?
HTTP ESPECIFICAÇÕES
(Alterado em Junho/2014) HTTP - RFC 2656 7230-7237 até http://tools.ietf.org/html/7230
http://tools.ietf.org/html/7237
URI - RFC 1738 e 3986 e http://tools.ietf.org/html/1738 http://tools.ietf.org/html/3986
COOKIES - RFC 2965 http://tools.ietf.org/html/2965
MAIS INFORMAÇÕES https://pt.wikipedia.org/wiki/Hypertext_Transfer_Protocol
DÚVIDAS?
Obrigado!