Last active
December 22, 2015 21:44
-
-
Save andy-williams/1532415b48dff1430201 to your computer and use it in GitHub Desktop.
.NET HttpClient Warning
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Main() | |
{ | |
using(var stream = File.Open(@"D:\test.txt", FileMode.Open)) | |
using(var httpClient = new HttpClient()) | |
{ | |
stream.Dump(); | |
var httpContent = new StreamContent(stream); | |
// pretty sweet test server by Henry Cipolla | |
// http://henrycipollablog.com/2011/12/06/testing-multipartform-data-uploads-with-post-test-server/ | |
var result = httpClient.PostAsync("http://posttestserver.com/post.php?dir=httpclient-test", httpContent).Result; | |
stream.Dump(); // stream closed | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment