Inheritance: IDisposable
Exemple #1
0
        /// <summary>
        /// Get the current cookies.
        /// You must have already have called EnableCookies()
        /// </summary>
        /// <returns></returns>
        public SList GetCookies()
        {
            IntPtr pCookies;

            curl_easy_getinfo(m_pCURL, CURLINFO.CURLINFO_COOKIELIST, out pCookies);
            SList list = new SList(pCookies);

            return(list);
        }
        public void Perform()
        {
            try
            {
                using (Curl curl = new Curl())
                {
                    WriteThis amazon = new WriteThis();
                    amazon.position = 0;
                    amazon.sizeleft = data.Length;

                    //Curl.GlobalInit((int)CURLinitFlag.CURL_GLOBAL_ALL);

                    curl.OnWriteCallback = new Curl.GenericCallbackDelegate(OnWriteData);

                    curl.OnReadCallback = new Curl.ReadCallbackDelegate(OnReadData);
                    curl.SetReadData(amazon);
                    curl.SetPostFieldSize(amazon.sizeleft);

                    curl.OnHeaderCallback = new Curl.GenericCallbackDelegate(OnHeaderData);

                    curl.SetUserAgent("Mozilla 4.0 (compatible; MSIE 6.0; Win32");
                    curl.SetUrl("http://www.amazon.com/exec/obidos/search-handle-form/002-5928901-6229641");
                    curl.SetPost();
                    curl.SetFollowLocation(true);

                    SList slist = new SList();
                    slist.Append("Accept: moo");
                    slist.Append("User-Agent: my agent");
                    curl.SetHeader(slist);

                    curl.EnableCookies("");

                    curl.Perform();

                    using (SList cookies = curl.GetCookies())
                    {
                        foreach (string cookie in cookies.Strings)
                            Console.WriteLine("{0}", cookie);
                    }

                    slist.Dispose();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
Exemple #3
0
 /// <summary>
 /// Set the Headers
 /// </summary>
 /// <param name="list"></param>
 /// <returns></returns>
 public CURLcode SetHeader(SList list)
 {
     return curl_easy_setopt(m_pCURL, CURLoption.CURLOPT_HTTPHEADER, list.Handle);
 }
Exemple #4
0
 /// <summary>
 /// Get the current cookies.
 /// You must have already have called EnableCookies()
 /// </summary>
 /// <returns></returns>
 public SList GetCookies()
 {
     IntPtr pCookies;
     curl_easy_getinfo(m_pCURL, CURLINFO.CURLINFO_COOKIELIST, out pCookies);
     SList list = new SList(pCookies);
     return list;
 }
Exemple #5
0
 /// <summary>
 /// Set the Headers
 /// </summary>
 /// <param name="list"></param>
 /// <returns></returns>
 public CURLcode SetHeader(SList list)
 {
     return(curl_easy_setopt(m_pCURL, CURLoption.CURLOPT_HTTPHEADER, list.Handle));
 }