Windows üzerinde test ediyorum, yük testi için POST isteklerini (farklı form değişkenleri ile) benzeştirmeye çalışıyorum. Her türlü yük testi yazılımını denedim ancak çalışmayı başaramadım. GET istekleri içinPOST isteği nasıl simüle edilir?
, ben sadece url
http://www.example.com?id=yyy&t=zzz
arkasında parametrelerini koyabilirsiniz biliyorum Ama nasıl bir POST isteği taklit mi?
Bir krom REST İstemcisine sahibim ancak başlıklara ve verilere ne yazacağımı bilmiyorum.
İşte ben bugüne kadar çalıştığım buydu:
class Program
{
static void Main(string[] args)
{
string viewstateid = "/wEPDwUKLTY3NjEyMzE4NWRkK4DxZpjTmZg/RGCS2s13vkEWmwWiEE6v+XrYoWVuxeg=";
string eventid ="/wEdAAoSjOGPZYAAeKGjkZOhQ+aKHfOfr91+YI2XVhP1c/pGR96FYSfo5JULYVvfQ61/Uw4pNGL67qcLo0vAZTfi8zd7jfuWZzOhk6V/gFA/hhJU2fx7PQKw+iST15SoB1LqJ4UpaL7786dp6laCBt9ubQNrfzeO+rrTK8MaO2KNxeFaDhrQ0hxxv9lBZnM1SHtoODXsNUYlOeO/kawcn9fX0BpWN7Brh7U3BIQTZwMNkOzIy+rv+Sj8XkEEA9HaBwlaEjg=";
string username = "user1";
string password = "ttee";
string loginbutton = "Log In";
string URLAuth = "http://localhost/login.aspx";
string postString = string.Format("VIEWSTATE={0}&EVENTVALIDATION={1}&LoginUser_UserName={2}&LoginUser_Password={3}&LoginUser_LoginButton={4}",viewstateid,eventid, username, password,realm,otp,loginbutton);
const string contentType = "application/x-www-form-urlencoded";
System.Net.ServicePointManager.Expect100Continue = false;
CookieContainer cookies = new CookieContainer();
HttpWebRequest webRequest = WebRequest.Create(URLAuth) as HttpWebRequest;
webRequest.Method = "POST";
webRequest.ContentType = contentType;
webRequest.CookieContainer = cookies;
webRequest.ContentLength = postString.Length;
webRequest.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1";
webRequest.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
webRequest.Referer = "http://localhost/login.aspx";
StreamWriter requestWriter = new StreamWriter(webRequest.GetRequestStream());
requestWriter.Write(postString);
requestWriter.Close();
StreamReader responseReader = new StreamReader(webRequest.GetResponse().GetResponseStream());
string responseData = responseReader.ReadToEnd();
Console.WriteLine(responseData);
responseReader.Close();
webRequest.GetResponse().Close();
}
}
Nasıl bu bir iç sadece çalışan geliştirme sunucuya yayınlarım? – stryba
Yapabileceğinden emin değilim. Bir geliştirme API'sini test etmek isterseniz, Postman chrome uygulamasını kullanmanızı öneririm veya API'nizi otomatik olarak test etmek isterseniz, bazı otomasyon araçlarını kullanmak zorunda kalırsınız (örneğin, Behat'i kullanabileceğiniz PHP için) –
Tam olarak benim amacım. – stryba