--------------
headers:
POST /login/ HTTP/1.0
Content-Type: application/x-www-form-urlencoded
Host: abc.test.com
Content-Length: 12
username=bobusername=bob
-----------------------
This is the code I am currently using
-----------------------
Expand|Select|Wrap|Line Numbers
- string post_data = "username=bob";
- string uri = "https://abc.test.com/login/";
- HttpWebRequest request = (HttpWebRequest)
- WebRequest.Create(uri);
- request.KeepAlive = false;
- request.ProtocolVersion = HttpVersion.Version10;
- request.Method = "POST";
- byte[] postBytes = Encoding.ASCII.GetBytes(post_data);
- request.ContentType = "application/x-www-form-urlencoded";
- request.ContentLength = postBytes.Length;
- Stream requestStream = request.GetRequestStream();
- requestStream.Write(postBytes, 0, postBytes.Length);
- MessageBox.Show(postBytes.Length.ToString());
- requestStream.Close();
- HttpWebResponse response = (HttpWebResponse)request.GetResponse();
- StreamReader sr = new StreamReader(response.GetResponseStream());
- string tmp = sr.ReadToEnd().Trim();
- -----------------------