node-curl
node-curl copied to clipboard
How to read response header from curl
How to read response header from curl ? Can you please share an example.
curl.on('end', function() { p('code: ' + curl.getinfo('RESPONSE_HTTPHEADER)); p('done.') curl.close(); });
Sorry for late reply, Header isn't saved, it must be add HEADERFUNCTION in C++ source file. I will patch it when I am free.
Thanks Jiangmioa. I will wait for the patch. Currently I'm doing an workaround. I set _curl.setopt(HEADER, 1). So I receive headers and content together as data (i.e. header1:value1\n\rheader2:value2\n\rContent). Now I parse the data and collect the headers and content in different variables. I'm not sure whether this is right way to go but it works.
Now node-curl supports read the header. it is at curl.header
. It need some more test, the package on npm will be updated some delay.
Its working fine now.