public void FollowRedirect(RedirectTest test)
 {
     var path = string.Format ("redirects/same-server/{0}/index.html", (int)test.Code);
     var response = GetResponse (path, test.Flags | PuppyFlags.AutoRedirect);
     try {
         Assert.AreEqual (HttpStatusCode.OK, response.StatusCode, "#1");
     } finally {
         response.Close ();
     }
 }
 public void NotWorking(RedirectTest test)
 {
     var path = string.Format ("redirects/same-server/{0}/index.html", (int)test.Code);
     var response = GetResponse (path, test.Flags);
     try {
         Assert.AreEqual (test.Code, response.StatusCode, "#1");
     } finally {
         response.Close ();
     }
 }
Example #3
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            EditingSetting = new RedirectTest()
            {
                Test = "https://www.bing.com/search?q=Example"
            };
            var param = Target = e.Parameter;

            if (param is IList <RedirectSetting> list)
            {
                IsAddMode = true;
            }
            else if (param is RedirectSetting setting)
            {
                IsAddMode             = false;
                EditingSetting.Input  = setting.Input;
                EditingSetting.Output = setting.Output;
                TitleInput.Text       = setting.Title;
            }
        }
        public void PostRedirect(RedirectTest test)
        {
            var prefix = string.Format ("redirects/same-server/{0}", (int)test.Code);
            var puppy = PostPuppy.CreateRequest (PuppyFlags.AutoRedirect, TransferMode.Chunked, prefix, "Hello Chunked World!");
            Console.WriteLine ("PUPPY: {0}", puppy);

            HttpWebResponse response;
            try {
                response = (HttpWebResponse)puppy.GetResponse ();
                Console.WriteLine ("GOT RESPONSE: {0}", response.StatusCode);
            } catch (WebException ex) {
                response = (HttpWebResponse)ex.Response;
                Console.WriteLine ("GOT ERROR RESPONSE: {0}", response.StatusCode);
            }

            using (var reader = new StreamReader (response.GetResponseStream ())) {
                var body = reader.ReadToEnd ();
                Console.WriteLine ("GOT RESPONSE BODY: {0}", body);
            }

            response.Close ();
        }