easy auth
marrrschine opened this issue · comments
adri commented
Hi,
I want to wrap my native curl call
curl.exe -i -Uuser:token -O "http://path/to/file.zip"
using CurlSharp.
First question:
Do I have to set user and token by
easy.UserAgent = "user";
easy.UserPwd = "token";
in CurlSharp?
Second question:
Can you give an example on how to modify OnWriteData
to handle my zip file.
Thanks a lot!
Masroor Ehsan commented
@marrrschine: Easiest way to provide authentication data is via the UserPwd property:
easy.UserPwd = "user:password";
You can save the downloaded buffer into a stream (file or memory). Once the entire file is downloaded, you may manipulate the zip archive. Pseudo-code:
public static Int32 OnWriteData(Byte[] buf, Int32 size, Int32 nmemb, Object extraData)
{
var nBytes = size*nmemb;
_stream.Write(buf, nBytes);
return nBytes;
}