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);
            }
        }
Esempio n. 2
0
        public void TestEnumerator()
        {
            // check that callback is called
            using (var list = new SList <OpaqueInt> ()) {
                list.Append(new OpaqueInt(1));
                list.Append(new OpaqueInt(2));
                list.Append(new OpaqueInt(3));
                int i = 1;
                foreach (var n in list)
                {
                    Assert.That(n.Value, Is.EqualTo(i++));
                }
            }

            Utility.AssertNoGLibLog();
        }
Esempio n. 3
0
        public void TestIndex()
        {
            using (var list = new SList <OpaqueInt> ()) {
                list.Append(new OpaqueInt(1));
                list.Append(new OpaqueInt(2));
                list.Append(new OpaqueInt(3));
                list.Append(new OpaqueInt(4));
                // check that finding an item returns the index
                var index = list.IndexOf(new OpaqueInt(3));
                Assert.That(index, Is.EqualTo(2));
                // check that not finding an item returns -1
                index = list.IndexOf(new OpaqueInt(5));
                Assert.That(index, Is.EqualTo(-1));
            }

            Utility.AssertNoGLibLog();
        }
Esempio n. 4
0
        public void TestConcat()
        {
            using (var list1 = new SList <OpaqueInt> ())
                using (var list2 = new SList <OpaqueInt> ()) {
                    list1.Append(null);
                    Assume.That(list1.Length, Is.EqualTo(1));
                    list2.Append(null);
                    list2.Append(null);
                    Assume.That(list2.Length, Is.EqualTo(2));
                    list1.Concat(list2);
                    Assert.That(list1.Length, Is.EqualTo(3));
                    Assert.That(list2.Length, Is.EqualTo(0));
                    Assert.That(() => list1.Concat(null), Throws.ArgumentNullException);
                }

            Utility.AssertNoGLibLog();
        }
Esempio n. 5
0
        public void TestAppend()
        {
            using (var list = new SList <OpaqueInt> ()) {
                Assume.That(list.Length, Is.EqualTo(0));
                list.Append(null);
                Assert.That(list.Length, Is.EqualTo(1));
            }

            Utility.AssertNoGLibLog();
        }