runtime: System.Net.Http.CurlException HttpClient PostAsync
Environment
DISTRIB_ID=Ubuntu DISTRIB_RELEASE=16.04 DISTRIB_CODENAME=xenial DISTRIB_DESCRIPTION=“Ubuntu 16.04 LTS”
Curl version
curl 7.47.0 (x86_64-pc-linux-gnu) libcurl/7.47.0 GnuTLS/3.4.10 zlib/1.2.8 libidn/1.32 librtmp/2.3 Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp smb smbs smtp smtps telnet tftp Features: AsynchDNS IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz TLS-SRP UnixSockets
Code
var client = new HttpClient() {
BaseAddress = new Uri("http://example.com/")
};
var formContent = new FormUrlEncodedContent(new[]
{
new KeyValuePair<string, string>("key", "val")
});
var response = await client.PostAsync("/some.php", formContent, CancellationToken.None);
Target
dotnet 1.0.0-preview1-002702 “System.Net.Http”: “4.0.1-rc2-24027”
Exception
Unhandled Exception: System.AggregateException: One or more errors occurred. (An error occurred while sending the request.) —> System.Net.Http.HttpRequestException: An error occurred while sending the request. —> System.Net.Http.CurlException: Failure when receiving data from the peer at System.Net.Http.CurlHandler.ThrowIfCURLEError(CURLcode error) at System.Net.Http.CurlHandler.MultiAgent.FinishRequest(EasyRequest completedOperation, CURLcode messageResult)
Run Curl directly is working
curl -c cookies.txt -b cookies.txt -X POST --form "key=val" http://example.com/some.php -L
Can’t get it working with dotnet, everything else just fine, except when I post FormUrlEncodedContent.
I tried different setup with HttpClientHandler, same exception.
Update!
Running with 1.0.0-preview2-003119 works fine.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 26 (14 by maintainers)
Commits related to this issue
- Add test for #9357 — committed to stephentoub/corefx by stephentoub 8 years ago
My workaround:
http://+:portbut onhttp://specific-ip:port.http://specific-ip:portfrom the client app.