My google app engine website is getting errors on the main url for HEAD requests because I am not accepting them. According to this, the HEAD request is for "testing hypertext links for validity, accessibility, and recent modification"
What should be my "normal" response to HEAD requests be?
I started accepting HEAD requests, to stop the errors from showing in my logs, but only on the main url.
Can someone point me in the right direction?
The HEAD method is used to ask only for information about a document, not for the document itself. HEAD is much faster than GET, as a much smaller amount of data is transferred. It's often used by clients who use caching, to see if the document has changed since it was last accessed.
What is the HTTP HEAD request method used for? The HTTP HEAD request is used to check the availability, size, and last modification date of a resource without downloading it (as indicated by the Content-Length and Last-Modified headers).
It is indeed plausible that a HEAD request would complete faster than GET, since it involves less data transfer. However, on a fast or high latency connection this almost always won't matter.
The HTTP HEAD method is almost identical to the GET method, but the only difference is that it will not return any response body. For example, if GET/users return a record of users, then HEAD/users make the same request, but it will not return any of the users' records.
Implement you head
method(s) just like the get
one(s), just skipping the writing of the body. You should do that for every URL that can be linked to, exactly because a well-behaved checker that's validating the links should use HEAD when it doesn't need the body.
Simplest is often to factor out the get
functionality to a separate auxiliary method _foo
that takes a boolean needbody
argument -- get
calls self._foo(True)
, head
calls self._foo(False)
. _foo
, if it sees its needbody
argument is false, can bail out as soon as it has generated all headers (and must make sure it doesn't generate a body).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With