Olá GUJ’s!
Estou estudando para o SCWCD, e tem uma parte do livro que naum entendi!!
Afinal, qual é a diferença entre os métodos GET e HEAD do protocolo HTTP? Pelo livro que estou estudando esta parte ficou meio obscura. Percebi que os dois são muito parecidos, mas não entendi quais são as limitações do método HEAD!
Se alguém puder dar uma luz quanto a esta dúvida, agradeço!
GET faz alguma coisa (por exemplo, puxar uma pagina); HEAD faz quase a mesma coisa que o GET, so que retorna um conteudo vazio. Esse metodo existe para checar se uma imagem foi atualizada no servidor, por exemplo. Na especificacao: This method is
often used for testing hypertext links for validity, accessibility,
and recent modification.
-
bom, aqui vai um excerto do RFC 2616 (Hypertext Transfer Protocol – HTTP/1.1).
[size=9]
9.3 GET
The GET method means retrieve whatever information (in the form of an
entity) is identified by the Request-URI. If the Request-URI refers
to a data-producing process, it is the produced data which shall be
returned as the entity in the response and not the source text of the
process, unless that text happens to be the output of the process.
The semantics of the GET method change to a “conditional GET” if the
request message includes an If-Modified-Since, If-Unmodified-Since,
If-Match, If-None-Match, or If-Range header field. A conditional GET
method requests that the entity be transferred only under the
circumstances described by the conditional header field(s). The
conditional GET method is intended to reduce unnecessary network
usage by allowing cached entities to be refreshed without requiring
multiple requests or transferring data already held by the client.
The semantics of the GET method change to a “partial GET” if the
request message includes a Range header field. A partial GET requests
that only part of the entity be transferred, as described in section
14.35. The partial GET method is intended to reduce unnecessary
network usage by allowing partially-retrieved entities to be
completed without transferring data already held by the client.
The response to a GET request is cacheable if and only if it meets
the requirements for HTTP caching described in section 13.
See section 15.1.3 for security considerations when used for forms.
9.4 HEAD
The HEAD method is identical to GET except that the server MUST NOT
return a message-body in the response. The metainformation contained
in the HTTP headers in response to a HEAD request SHOULD be identical
to the information sent in response to a GET request. This method can
be used for obtaining metainformation about the entity implied by the
request without transferring the entity-body itself. This method is
often used for testing hypertext links for validity, accessibility,
and recent modification.
The response to a HEAD request MAY be cacheable in the sense that the
information contained in the response MAY be used to update a
previously cached entity from that resource. If the new field values
indicate that the cached entity differs from the current entity (as
would be indicated by a change in Content-Length, Content-MD5, ETag
or Last-Modified), then the cache MUST treat the cache entry as
stale.
[/size]
Viche!!!
Valeu Thingol!
Agora eu entendi!!!
Foquei com essa dúvida cutucando a cabeça desde ontem à tarde!!
Obrigado!