node-curl icon indicating copy to clipboard operation
node-curl copied to clipboard

How to read response header from curl

Open somnathwy opened this issue 11 years ago • 4 comments

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(); });

somnathwy avatar May 16 '13 09:05 somnathwy

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.

jiangmiao avatar May 20 '13 20:05 jiangmiao

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.

somnathwy avatar May 21 '13 09:05 somnathwy

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.

jiangmiao avatar May 25 '13 08:05 jiangmiao

Its working fine now.

somnathwy avatar Aug 29 '13 10:08 somnathwy