Codemetric optimized httpwebrequest in C#
- by Omegavirus
Hello,
the problem is the httpwebrequest method in my c# program. visual studio gives it a metric of 60, thats pretty lame.. so how can i program it more efficient? (:
my actual code:
public string httpRequest(string url)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "GET";
request.Proxy = WebRequest.DefaultWebProxy;
request.MediaType = "HTTP/1.1";
request.ContentType = "text/xml";
request.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.1; de; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12";
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader streamr = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
String sresp = streamr.ReadToEnd();
streamr.Close();
return sresp;
}
thanks for helping. ;)