Last active
December 19, 2015 23:59
-
-
Save sergeevyi/6038472 to your computer and use it in GitHub Desktop.
post data through httpWebRequest
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CookieContainer cookieJar = new CookieContainer(); | |
var request = (HttpWebRequest)HttpWebRequest.Create("http://www.google.com"); | |
request.Method = "POST"; | |
request.ContentType = "application/x-www-form-urlencoded"; | |
request.CookieContainer = cookieJar; | |
var response = request.GetResponse(); | |
foreach (Cookie c in cookieJar.GetCookies(request.RequestUri)) | |
{ | |
Console.WriteLine("Cookie['" + c.Name + "']: " + c.Value); | |
} | |
/* | |
foreach (Cookie c in cookieJar.GetCookies(request.RequestUri)) | |
{ | |
Debug.Log("Cookie['" + c.Name + "']: " + c.Value); | |
} | |
*/ | |
// Debug.Log("found cookie:"+); | |
/* if (www2.responseHeaders.ContainsKey("session")) | |
{ | |
Debug.Log("found cookie:"); | |
// extract the session identifier cookie and save it | |
// the cookie will be named, "auth" (this could be something else in your case) | |
char[] splitter = { ';' }; | |
string[] v = www2.responseHeaders["SET-COOKIE"].Split(splitter); | |
foreach (string s in v) | |
{ | |
if (string.IsNullOrEmpty(s)) continue; | |
if (s.Substring(0, 4).ToLower().Equals("auth")) | |
{ // found it | |
// Game.Instance.SetSessionCookie(s); | |
Debug.Log("cookie:"+s); | |
break; | |
} | |
} | |
} | |
*/ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment