对于使用 HttpWebRequest 的 POST 请求,当我写入请求流时,数据会在什么时候发送?是在我关闭请求流时还是在我调用 GetResponse 时?是否需要 GetResponse 调用?
.net 文档似乎不太清楚到底发生了什么
这是我很好奇的代码:
HttpWebRequest request = HttpWebRequest.Create(url) as HttpWebRequest;
request.Method = "POST";
request.ContentLength = jsonData.Length;
request.ContentType = "application/json";
Stream requestStream = request.GetRequestStream();
requestStream.Write(jsonData, 0, jsonData.Length);
requestStream.Close();
var response = request.GetResponse() as HttpWebResponse;
谢谢!