sync-request icon indicating copy to clipboard operation
sync-request copied to clipboard

Error thrown when changing HTTP method to HEAD instead of GET

Open markSmurphy opened this issue 3 years ago • 2 comments

I'm writing a utility which validates response headers on an array of URLs. So I don't need to download the resource, just the headers but when issuing a HEAD request to achive this an error is reported.

To reproduce, modify the example to use HEAD and to write the response headers to the console rather than the response body:

var request = require('sync-request'); var res = request('HEAD', 'http://example.com'); console.log(res.headers);

I get:

/home/mark/sync-request/node_modules/sync-rpc/lib/index.js:167 throw error; ^

Error: unexpected end of file at extractValue (/home/mark/sync-request/node_modules/sync-rpc/lib/index.js:165:19) at /home/mark/sync-request/node_modules/sync-rpc/lib/index.js:175:12 at request (/home/mark/sync-request/node_modules/sync-request/lib/index.js:28:15) at Object. (/home/mark/sync-request/index.js:2:11) at Module._compile (internal/modules/cjs/loader.js:816:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:827:10) at Module.load (internal/modules/cjs/loader.js:685:32) at Function.Module._load (internal/modules/cjs/loader.js:620:12) at Function.Module.runMain (internal/modules/cjs/loader.js:877:12) at internal/main/run_main_module.js:21:11

markSmurphy avatar Jul 10 '20 17:07 markSmurphy

+1

wizardforcel avatar Sep 19 '20 03:09 wizardforcel

+2

udondan avatar Dec 02 '20 08:12 udondan