RestSharp - 如何获取数字 http 响应代码?
RestSharp - How do I get the numerical http response code?
我正在使用 C# 的 RestSharp HTTP 客户端库。
如何检索实际的数字 http 响应代码?我不仅没有看到 属性 包含数字代码,而且我什至没有在 headers collection.
中看到它
只需从 RestResponse 对象中获取 StatusCode 属性 并将枚举值转换为 int。
RestResponse response = client.Execute(request);
HttpStatusCode statusCode = response.StatusCode;
int numericStatusCode = (int)statusCode;
Assert.Equal(200, (int)response.StatusCode);
我正在使用 C# 的 RestSharp HTTP 客户端库。
如何检索实际的数字 http 响应代码?我不仅没有看到 属性 包含数字代码,而且我什至没有在 headers collection.
中看到它只需从 RestResponse 对象中获取 StatusCode 属性 并将枚举值转换为 int。
RestResponse response = client.Execute(request);
HttpStatusCode statusCode = response.StatusCode;
int numericStatusCode = (int)statusCode;
Assert.Equal(200, (int)response.StatusCode);