daily pastebin goal
68%
SHARE
TWEET

Untitled

a guest Apr 16th, 2018 530 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public virtual bool Run()
  2.     {
  3.         var request = CreateRequest();
  4.         var response = GetResponse(request);
  5.         var responseString = ReadResponse(response);
  6.         this.SetResults(responseString);
  7.         return this.IsSuccessful;
  8.     }
  9.  
  10.     protected internal virtual HttpWebRequest CreateRequest()
  11.     {
  12.         var address = TestConfig.Address;
  13.  
  14.         var request = (HttpWebRequest)WebRequest.Create(address);
  15.  
  16.         request.Accept = "*/*";
  17.         request.UseDefaultCredentials = true;
  18.         request.CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore);
  19.  
  20.         return request;
  21.     }
  22.  
  23.     protected internal virtual HttpWebResponse GetResponse(HttpWebRequest request)
  24.     {
  25.         var response = (HttpWebResponse) request.GetResponse();
  26.  
  27.         return response;
  28.     }
  29.  
  30.     protected internal virtual string ReadResponse(HttpWebResponse response)
  31.     {
  32.         var stream = response.GetResponseStream();
  33.         var responseString = ReadResponse(stream);
  34.  
  35.         stream.Close();
  36.         response.Close();
  37.  
  38.         return responseString;
  39.     }
  40.  
  41.     protected internal virtual string ReadResponse(Stream stream)
  42.     {
  43.         var reader = new StreamReader(stream);
  44.         var responseString = reader.ReadToEnd();
  45.         return responseString;
  46.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top