我使用 ResponseWriter 使用 RestSharp 下载流。
var client = new RestClient
var request = new RestRequest();
// ...
request.ResponseWriter = (ms) => {
// how to detect the status code
};
var response = client.Execute(request);
如何在 ResponseWriter 中找到 HTTP 状态代码? 有没有更好的方法来下载流?
最佳答案
执行请求后可以查看response.StatusCode和response.StatusDescription。
有趣的是,如果您使用此处所述的 DownloadData 方法 https://github.com/restsharp/RestSharp/wiki/Other-Usage-Examples据我所知,无法访问此信息。
关于http - 使用 RestSharp 和 ResponseWriter 下载流,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26273135/