Terminologia do protocolo HTTP
2011-2012
Metodologias de Programação IV
http://www.tribunalconstitucional.pt/tc/home.html
Cliente HTTP(por ex.,
o navegador)
Servidor HTTP(Apache, IIS,
etc.)
Mensagem dopedido HTTP
(Porto 80 de TCP)
Mensagem daresposta HTTP
Cliente HTTP(por ex.,
o navegador)
Servidor HTTP(Apache, IIS,
etc.)
Mensagem dopedido HTTP
Mensagem daresposta HTTP
Protocolo sem estado (“stateless”)
Cliente HTTP(por ex., o
navegador)
Servidor HTTP(IIS, Apache,
etc.)
Pedido
Resposta
Proxy
ProxyPedido
Resposta
RespostaPedido
RespostaPedido
Mais proxies e c.ª
Pedidos e
Respostassão
Mensagensdo protocolo HTTP
Mensagens do HTTP
PedidoLinha de pedido CRLFLinhas de cabeçalhos CRLFCRLFCorpo
RespostaLinha de estado CRLFLinhas de cabeçalhos CRLFCRLFCorpo
Mensagens do HTTP
PedidoLinha de pedido CRLFLinhas de cabeçalhos CRLFCRLFCorpo
RespostaLinha de estado CRLFLinhas de cabeçalhos CRLFCRLFCorpo
Linha de pedido:Método URI-do-pedido Versão-do-HTTP
Mensagens do HTTP
PedidoLinha de pedido CRLFLinhas de cabeçalhos CRLFCRLFCorpo
RespostaLinha de estado CRLFLinhas de cabeçalhos CRLFCRLFCorpo
Linha de estado:Versão-do-HTTP Código-de-estado Motivo
http://www.tribunalconstitucional.pt/tc/home.html
Pedido HTTP
GET /tc/home.html HTTP/1.1Host: www.tribunalconstitucional.pt
http://www.tribunalconstitucional.pt/tc/home.html
Pedido HTTP
GET /tc/home.html HTTP/1.1Host: www.tribunalconstitucional.pt
Linha de pedido
http://www.tribunalconstitucional.pt/tc/home.html
Pedido HTTP
GET /tc/home.html HTTP/1.1Host: www.tribunalconstitucional.pt
Linha de cabeçalho
http://www.tribunalconstitucional.pt/tc/home.html
Resposta HTTP
HTTP/1.1 200 OKContent-Type: text/htmlContent-Length: 9934...<HTML>...
http://www.tribunalconstitucional.pt/tc/home.html
Resposta HTTP
HTTP/1.1 200 OKContent-Type: text/htmlContent-Length: 9934...<HTML>...
Linha de estado
Linhas de cabeçalhos
Corpo
http://www.tribunalconstitucional.pt/tc/conteudo/files/pagina/mouraramos.jpg
Resposta HTTP
HTTP/1.1 200 OKContent-Type: image/jpegContent-Length: 26610...ÿØÿà JFIF ð ð ÿÛ C
Métodos dos pedidos• HTTP 0.9– GET
• HTTP 1.0– HEAD– POST
• HTTP 1.1– PUT– DELETE– OPTIONS– TRACE– CONNECT
Métodos dos pedidos
Pedir um recurso (página Web, imagem, etc.)
• HTTP 0.9– GET
• HTTP 1.0– HEAD– POST
• HTTP 1.1– PUT– DELETE– OPTIONS– TRACE– CONNECT
Métodos dos pedidos
Pedir para enviar informações no corpo do pedido (para submeter formulários, por
exemplo)
• HTTP 0.9– GET
• HTTP 1.0– HEAD– POST
• HTTP 1.1– PUT– DELETE– OPTIONS– TRACE– CONNECT
Métodos dos pedidos• HTTP 0.9– GET
• HTTP 1.0– HEAD– POST
• HTTP 1.1– PUT– DELETE– OPTIONS– TRACE– CONNECT
Pedir só os cabeçalhos de um recurso (headers),
não o corpo.Para comparar versões, por ex.
Métodos dos pedidos• HTTP 0.9– GET
• HTTP 1.0– HEAD– POST
• HTTP 1.1– PUT– DELETE– OPTIONS– TRACE– CONNECT
Pedir para guardar um recurso no
servidor (upload).
Formulário
<formname="Pesquisa“method="post“action="contactos/temp.asp“><input name="txtPesquisa" type="text“ alt="Procura alguém?" size="13“
maxlength="255"> <input name="Pesquisar" type="image“ id="Pesquisar" title="Pesquisar“ src="/img/pt/tmpl/lupa.gif” alt="Pesquisar" width="26" height="21" border="0"> </form>
<formname="Pesquisa“method="post“action="contactos/temp.asp“><input name="txtPesquisa" type="text“ alt="Procura alguém?" size="13“
maxlength="255"> <input name="Pesquisar" type="image“ id="Pesquisar" title="Pesquisar“ src="/img/pt/tmpl/lupa.gif” alt="Pesquisar" width="26" height="21" border="0"> </form>
Qual a diferença entre usar “POST” ou “GET” neste formulário?
Leonel
<formname="Pesquisa“method=“get“action="contactos/temp.asp“><input name="txtPesquisa" type="text“ alt="Procura alguém?" size="13“
maxlength="255"> <input name="Pesquisar" type="image“ id="Pesquisar" title="Pesquisar“ src="/img/pt/tmpl/lupa.gif” alt="Pesquisar" width="26" height="21" border="0"> </form>
Pedido HTTP
GET /pt/contactos/temp.asp?txtPesquisa=Leonel HTTP/1.1Host: www.utad.pt
<formname="Pesquisa“method="post“action="contactos/temp.asp“><input name="txtPesquisa" type="text“ alt="Procura alguém?" size="13“
maxlength="255"> <input name="Pesquisar" type="image“ id="Pesquisar" title="Pesquisar“ src="/img/pt/tmpl/lupa.gif” alt="Pesquisar" width="26" height="21" border="0"> </form>
Pedido HTTP
POST /pt/contactos/temp.asp/ HTTP/1.1Host: www.utad.pt
txtPesquisa=Leonel
Leituras associadas
Web Application Architecture, Second EditionCap. 3: “Birth of theWeb: HTTP”, págs. 29 a 41.
Hypertext Transfer Protocol -- HTTP/1.1http://www.w3.org/Protocols/rfc2616/rfc2616.html
ELEMENTOS DO HTTP(CÓDIGOS DE ESTADO, CABEÇALHOS E TIPOS MIME)
Próxima aula