Browse code

Little fix to the .NET cookies handling.

Pierre-David BeĢlanger authored on 28/07/2015 19:50:36
Showing 1 changed files
... ...
@@ -43,13 +43,12 @@ namespace ChatterBotAPI
43 43
     internal class CleverbotSession : ChatterBotSession
44 44
     {
45 45
         private readonly int endIndex;
46
-        private readonly string baseUrl;
47 46
         private readonly string url;
48 47
         private readonly IDictionary<string, string> vars;
48
+		private readonly CookieCollection cookies;
49 49
 
50 50
         public CleverbotSession(string baseUrl, string url, int endIndex)
51 51
         {
52
-            this.baseUrl = baseUrl;
53 52
             this.url = url;
54 53
             this.endIndex = endIndex;
55 54
             vars = new Dictionary<string, string>();
... ...
@@ -59,6 +58,7 @@ namespace ChatterBotAPI
59 58
             vars["sub"] = "Say";
60 59
             vars["islearning"] = "1";
61 60
             vars["cleanslate"] = "false";
61
+			cookies = Utils.GetCookies(baseUrl);
62 62
         }
63 63
 
64 64
         public ChatterBotThought Think(ChatterBotThought thought)
... ...
@@ -70,8 +70,6 @@ namespace ChatterBotAPI
70 70
             var formDataDigest = Utils.MD5(formDataToDigest);
71 71
             vars["icognocheck"] = formDataDigest;
72 72
 
73
-            var cookies = Utils.GetCookies(baseUrl);
74
-            
75 73
             var response = Utils.Post(url, vars, cookies);
76 74
 
77 75
             var responseValues = response.Split('\r');