SeasideResearch.LibCurlNet.Easy.GetInfo C# (CSharp) Method

GetInfo() public method

Extract DateTime information from an Easy object.
This is thrown if /// the native CURL* handle wasn't created successfully.
public GetInfo ( CURLINFO info, System.DateTime &dt ) : CURLcode
info CURLINFO One of the values in the /// enumeration. In this case, it must /// specifically be . ///
dt System.DateTime Reference to a DateTime value.
return CURLcode
        public CURLcode GetInfo(CURLINFO info, ref DateTime dt)
        {
            EnsureHandle();
            CURLcode retCode = CURLcode.CURLE_OK;
            IntPtr ptr = IntPtr.Zero;

            if (info != CURLINFO.CURLINFO_FILETIME)
                return CURLcode.CURLE_BAD_FUNCTION_ARGUMENT;

            retCode = External.curl_easy_getinfo(m_pCURL, info, ref ptr);
            if (retCode == CURLcode.CURLE_OK)
            {
                if ((int)ptr < 0)
                    dt = new DateTime(0);
                else
                {
                    int yy = 0, mm = 0, dd = 0, hh = 0, mn = 0, ss = 0;
                    External.curl_shim_get_file_time((int)ptr, ref yy,
                        ref mm, ref dd, ref hh, ref mn, ref ss);
                    dt = new DateTime(yy, mm, dd, hh, mn, ss);
                }
            }
            return retCode;
        }

Same methods

Easy::GetInfo ( CURLINFO info, Object &objInfo ) : CURLcode
Easy::GetInfo ( CURLINFO info, SeasideResearch.LibCurlNet.Slist &slist ) : CURLcode
Easy::GetInfo ( CURLINFO info, double &dblVal ) : CURLcode
Easy::GetInfo ( CURLINFO info, int &intVal ) : CURLcode
Easy::GetInfo ( CURLINFO info, string &strVal ) : CURLcode

Usage Example

Beispiel #1
1
        public static bool gopost(string url, string user, string password,  string data, TradeLink.API.DebugDelegate deb, out string result)
        {
            debs = deb;
            Curl.GlobalInit((int)CURLinitFlag.CURL_GLOBAL_ALL);

            Easy easy = new Easy();
            rresult = new StringBuilder();
            hasresult = false;

            Easy.WriteFunction wf = new Easy.WriteFunction(OnWritePostData);
            easy.SetOpt(CURLoption.CURLOPT_WRITEFUNCTION, wf);
            Easy.DebugFunction df = new Easy.DebugFunction(OnDebug);
            easy.SetOpt(CURLoption.CURLOPT_DEBUGFUNCTION, df);

            // simple post - with a string
            easy.SetOpt(CURLoption.CURLOPT_POSTFIELDS,
                data);
            Slist sl = new Slist();
            sl.Append("Content-Type:application/xml");
            sl.Append("Accept: application/xml");
            easy.SetOpt(CURLoption.CURLOPT_HTTPHEADER, sl);
            easy.SetOpt(CURLoption.CURLOPT_SSL_VERIFYPEER, false);
            easy.SetOpt(CURLoption.CURLOPT_USERAGENT,
                "Mozilla 4.0 (compatible; MSIE 6.0; Win32");
            easy.SetOpt(CURLoption.CURLOPT_FOLLOWLOCATION, true);
            easy.SetOpt(CURLoption.CURLOPT_USERPWD, user + ":" + password);
            CURLhttpAuth authflag = CURLhttpAuth.CURLAUTH_BASIC;
            easy.SetOpt(CURLoption.CURLOPT_HTTPAUTH, authflag);
            easy.SetOpt(CURLoption.CURLOPT_URL,url);
            
            easy.SetOpt(CURLoption.CURLOPT_POST, true);
            if (debs!=null)
                easy.SetOpt(CURLoption.CURLOPT_VERBOSE, true);
            


            CURLcode err = easy.Perform();
            int waits = 0;
            int maxwaits = 200;
            while (!hasresult && (waits++<maxwaits))
                System.Threading.Thread.Sleep(10);

            int rcodei = 0;
            CURLcode rcode = easy.GetInfo(CURLINFO.CURLINFO_RESPONSE_CODE, ref rcodei);


            if (!hasresult && (deb != null))
                deb(easy.StrError(err));

            easy.Cleanup();



            Curl.GlobalCleanup();
            result = rresult.ToString();



            return hasresult;
        }
All Usage Examples Of SeasideResearch.LibCurlNet.Easy::GetInfo