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