令我惊讶的是,从.NET BCL中我可以看出,我无法做到这么简单。
byte[] response = Http.Post( url: "http://dork.com/service", contentType: "application/x-www-form-urlencoded", contentLength: 32, content: "home=Cosby&favorite+flavor=flies");
上面的假设代码使用数据进行HTTP POST,并从Post
静态类的方法返回响应Http
。
既然我们没有这么容易,那么下一个最佳解决方案是什么?
如何发送带有数据的HTTP POST并获取响应的内容?