dotnet-httpclient

How can I get negotiated TLS version used in HttpClient POST requests

感情迁移 提交于 2020-07-09 11:52:07
问题 I am trying to get the TLS version information used in my HttpClient SendAsync calls. I have tried method from this link Detecting TLS Version used for HttpClient POST or GET calls but when I ran it in debug mode I have found that the object disposed exception comes while getting SslProtocol property. Is there any way that I can stop .net disposing the object properties until I read them. Here is the code: public bool ExecuteAsync() { using (var client = new HttpClient()) { using (var

Uploading large files to Controller in chunks using HttpClient, IFormFile always empty

帅比萌擦擦* 提交于 2020-07-09 05:26:44
问题 I am trying to create a .Net Standard "Client" class for uploading (sometimes very large) files to a Controller. I want to do this by breaking the file into chunks and uploading them one at a time. The intent is for other applications to use this instead of communicating directly to the Web Api. I already have the Controller working. I've verified that it works using a Kendo-ui control which supports chunk-saving. The issue I am having is that the IEnumerable<IFormFile> files parameter for my

Uploading large files to Controller in chunks using HttpClient, IFormFile always empty

柔情痞子 提交于 2020-07-09 05:26:12
问题 I am trying to create a .Net Standard "Client" class for uploading (sometimes very large) files to a Controller. I want to do this by breaking the file into chunks and uploading them one at a time. The intent is for other applications to use this instead of communicating directly to the Web Api. I already have the Controller working. I've verified that it works using a Kendo-ui control which supports chunk-saving. The issue I am having is that the IEnumerable<IFormFile> files parameter for my

Is it possible to make HttpClient ignore invalid ETag header in response?

被刻印的时光 ゝ 提交于 2020-06-27 14:47:48
问题 I'm working on an application which makes a web service request using the HttpClient API to a third party service over which I have no control. The service seems to respond to requests with an ETag HTTP header containing an invalid value according to the HTTP specification (the value is not enclosed in quotation marks). This causes the HttpClient to fail with a System.FormatException . In this case I am not interested in the ETag header and would like to be able to ignore the invalid value.

Is it possible to make HttpClient ignore invalid ETag header in response?

放肆的年华 提交于 2020-06-27 14:47:31
问题 I'm working on an application which makes a web service request using the HttpClient API to a third party service over which I have no control. The service seems to respond to requests with an ETag HTTP header containing an invalid value according to the HTTP specification (the value is not enclosed in quotation marks). This causes the HttpClient to fail with a System.FormatException . In this case I am not interested in the ETag header and would like to be able to ignore the invalid value.

Fix checksum in Artifactory when uploading file through REST API

夙愿已清 提交于 2020-06-25 09:21:29
问题 I'm using the code below to upload a file through Artifactory's REST API. My problem is that when I view the file through the GUI I get this message: Client did not publish a checksum value. If you trust the uploaded artifact you can accept the actual checksum by clicking the 'Fix Checksum' button. How do I fix the upload so that this message disappears? If I upload the file through the GUI I'm not supplying checksum values so why do I have to do it when I use the API? Is there an extra

Fix checksum in Artifactory when uploading file through REST API

廉价感情. 提交于 2020-06-25 09:21:22
问题 I'm using the code below to upload a file through Artifactory's REST API. My problem is that when I view the file through the GUI I get this message: Client did not publish a checksum value. If you trust the uploaded artifact you can accept the actual checksum by clicking the 'Fix Checksum' button. How do I fix the upload so that this message disappears? If I upload the file through the GUI I'm not supplying checksum values so why do I have to do it when I use the API? Is there an extra

How to make HttpClient ignore Content-Length header

时光总嘲笑我的痴心妄想 提交于 2020-06-24 22:47:45
问题 I am using HttpClient to communicate with a server which I don't have access to. Sometimes the JSON response from the server is truncated. The problem occurs when the Content-Length header is smaller than what it should be (8192 vs. 8329). It seems like a bug on the server which gives a smaller Content-Length header than the actual size of the response body. If I use Google Chrome instead of HttpClient, the response is always complete. Therefore, I want to make HttpClient to ignore the wrong

HttpClient.GetStreamAsync() with custom request?

旧巷老猫 提交于 2020-06-16 07:25:23
问题 My goal is to use the HttpClient class to make a web-request so that I can write the response to a file (after parsing). Therefore I need the result as a Stream . HttpClient.GetStreamAsync() only takes the string requestUri as parameter. So there is no possibility to create a request with custom HttpRequestHeader , custom HttpMethod , custom ContentType , custom content and so on? I saw that HttpWebRequest is sometimes used instead, but in my PCL (Profile111) there is no Add method for the

HttpClient.GetAsync times out when connected to VPN

北战南征 提交于 2020-06-12 06:05:14
问题 C# 4.5.2 framework HttpClient.GetAsync() method works fine on Windows 10 when system is not using VPN. When VPN is connected HttpClient.GetAsync() call to the same address just blocks until it times out. Both Edge and Chrome have no issues accessing that same address. Is there a way to see what is happening? What is HttpClient doing differently? Update: Got some interesting clues by calling Dns.GetHostEntry() . Without VPN this call returned only IPv4 addresses that all could be connected to.