Search code examples
phphttpcurlhttp-status-code-404curl-multi

targeted http request status code only or file size only making sure to put least possible load/traffic on the destination server


if curl --head http://.... includes "301" or "404" then ... if curl --head http://.... has content-Length > 1000000 then ...

how to be put the least possible load on the destination server when doing many of such requests?

is it possible to only request the first line of the http answer or even only the 3 digits of the status code(/content length) but nothing else, to minimize traffic?

(actually, is there any alternative http field next to content-length indicating file size?)

thanks!


Solution

  • If you cannot modify server to return something small and useful - then the only option is HEAD http method to request only headers of response, all methods can be found here.

    Content-length is standard way to tell the length of HTTP body, there are no other ways or they are very server specific, check http rfc