Is it possible to send HEAD request with RestSharp?

倾然丶 夕夏残阳落幕 提交于 2019-12-12 04:56:44

问题


I'm trying to send HEAD request to server to get a file length from Content-Length header, but I always get 'Not Acceptable' in response when I'm using RestSharp. Id I create request with simple .NET WebRequest it work good.

I tried to clear all header and other stuff from request and client, but had no success

Is it possible to do this request with RestSharp and how?

Thanks in advance


回答1:


Try this

var request = new RestRequest("/resource", Method.HEAD);



回答2:


Solve the problem with

restRequest.Parameters.Clear();
restRequest.AddHeader("Accept", "*/*");


来源:https://stackoverflow.com/questions/29668988/is-it-possible-to-send-head-request-with-restsharp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!