To avoid null reference passed to the StreamReader you need to restructure your code like this.
string respHtml = "";
HttpWebResponse resp = getUrlResponse(url, headerDict, postDict, timeout, postDataStr);
if (resp != null)
{
var respStream = resp.GetResponseStream();
if (respStream != null)
{
using (var sr = String.IsNullOrEmpty(charset)
? new StreamReader(respStream)
: new StreamReader(respStream, Encoding.GetEncoding(charset)))
{
respHtml = sr.ReadToEnd();
}
}
}
return respHtml;