public WebReq(string _siteName, getPost _opType, Connection _connection, bool _silent = true, string _strBuffer = "") { HttpWebRequest localRequest; string requestMethod; hostSiteName = _siteName; currentRequest = _opType; formConnection = _connection; switch (currentRequest) { case getPost.get: webRequestGET = (HttpWebRequest)WebRequest.Create(_siteName); requestMethod = "GET"; localRequest = webRequestGET; break; case getPost.post: webRequestPOST = (HttpWebRequest)WebRequest.Create(_siteName); requestMethod = "POST"; localRequest = webRequestPOST; break; default: localRequest = null; requestMethod = ""; break; } localRequest.ContentType = "application/x-www-form-urlencoded"; localRequest.Method = requestMethod; addCookie(localRequest, formConnection); if (_strBuffer.Length != 0 && currentRequest == getPost.post) { byte[] buffer = Encoding.ASCII.GetBytes(_strBuffer); localRequest.ContentLength = buffer.Length; Stream PostData = localRequest.GetRequestStream(); PostData.Write(buffer, 0, buffer.Length); PostData.Close(); } webResponse = (HttpWebResponse)localRequest.GetResponse(); Answer = webResponse.GetResponseStream(); }
public WebReq(string _siteName, getPost _opType, Connection _connection) : this(_siteName, _opType, _connection, true, "") { }