1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
private const int shopEncoding = 28591;
private string GetStream(string chUrl)
{
string stream = "";
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(chUrl);
request.Timeout = 30000;
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
using (Stream mystream = response.GetResponseStream())
{
using (StreamReader mystreamreader = new StreamReader(mystream, Encoding.GetEncoding(shopEncoding)))
{
stream = mystreamreader.ReadToEnd().Replace("\r\n", "\n").Replace("\n", "\r\n");
}
}
}
catch (UrlEncodeException e)
{
// gestion de l'exception
}
return stream;
}
private string UrlEncode(string strToEncode)
{
string strEncode = "";
try
{
strEncode = HttpUtility.UrlEncode(strToEncode, Encoding.GetEncoding(shopEncoding));
}
catch
{
throw new UrlEncodeException("Impossible d'encoder le caractère, l'instruction a été stoppé");
}
return strEncode;
} |
Partager