Webrequest不向主机发送标头

时间:2017-02-23 16:47:37

标签: c# windows service

我的代码

我正在尝试向主机发送自定义标头,但是当他们收到数据时,他们没有收到标头:

request = (HttpWebRequest)WebRequest.Create(Common.GatewayUrl(Gateway, UsingTestGateway));
strCookieHeader = "[machine=" + ThreeDSecure.Cavv + " path=null domain=null; ]";
request.Headers.Add("cookies", strCookieHeader);
//request.Headers.Add("machine", ThreeDSecure.Cavv);
//request.Headers.Add("path", "null");
//request.Headers.Add("domain", "null");
//request.ContentType = Common.ContentType(Gateway);
//request.Headers[HttpRequestHeader.Cookie] = strCookieHeader;
//request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
request.Credentials = merchantCredentials;
request.ContentLength = requestData.Length;
request.Timeout = 60000;
request.Method = "POST";

sw = new StreamWriter(request.GetRequestStream());
sw.Write(requestData);
sw.Flush();
sw.Close();

response = (HttpWebResponse)request.GetResponse();
sr = new StreamReader(response.GetResponseStream());
responseData = sr.ReadToEnd();

sr.Close();

0 个答案:

没有答案