Send a HEAD request to the Google Script app

I am developing a Google Script application to determine the size of a remote resource without downloading it . The code is as follows

function getRemoteFileSize()
{  
  var params =  { "method" : "head" };
  var resp = UrlFetchApp.fetch("https://www.google.com/images/srpr/logo11w.png", params);
  Logger.log("Remote File Size: " + resp.getAllHeaders()["Content-Length"]);
}

However, Google App Script does not seem to support head-end queries, and the code above cannot be executed.

What could be a viable alternative besides issuing a request GET?
I am open to all offers, including the use of a third-party service with an API

+4
source share
1 answer

You must use the method override in the parameters:

var params = {"method" : "GET", "headers": {"X-HTTP-Method-Override": "HEAD"}};

"HEAD", , , override "PATCH", , .

+3

All Articles