GETリクエスト時にファイルにリクエストヘッダ情報を付加
1543 ワード
///
/// GET ,
///
///
///
public static string myGetWebContent(string myUrl, string charset)
{
//HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(url);
//myReq.Method = "GET";
//myReq.Headers.Add("Authorization", " ");
//HttpWebResponse res = (HttpWebResponse)myReq.GetResponse();
//res.GetResponseStream();
if (charset == "") charset = "utf-8";
WebRequest request7 = WebRequest.Create(myUrl);
request7.Method = "GET";
//post
//string postdata = "LoginName=test";
//byte[] bytes = Encoding.ASCII.GetBytes(myPara);
//request7.ContentType = "application/x-www-form-urlencoded";
request7.Headers.Add("Authorization", " ");
//request7.ContentLength = myPara.Length;
//Stream sendStream = request7.GetRequestStream();
//sendStream.Write(bytes, 0, bytes.Length);
//sendStream.Close();
//
WebResponse response7 = request7.GetResponse();
string OrderQuantity = new StreamReader(response7.GetResponseStream(), Encoding.GetEncoding(charset)).ReadToEnd();
return OrderQuantity;
}
:https://bbs.csdn.net/topics/390588474