another tech blog to share my struggle with HTTP PUT. C# offers many ways to upload files, the simplest is using WebClient, however it failed with out of memory on large files.
During the testing I received many different problems
- System.NotSupportedException: The stream does not support concurrent IO read or write operations.
- System.OutOfMemoryException
- The server committed a protocol violation. Section=ResponseStatusLine
- And few more I forgot but will add later, maybe...
HttpWebRequest request = new ...
request.SendChunked = true;
Concurrent IO operations:
HttpWebRequest request = new ...
request.AllowWriteStreamBuffering = false;
Protocol violation:
Create a web.config file near your exe with useUnsafeHeaderParsing=“true“, search web how to do that properly. But that was not acceptable in our case as we had both source codes, client and server. The server was not sending response or not a standard response with proper headers. So after uopload we removed the wait for a response:
HttpWebResponse response = (HttpWebResponse)request.GetResponse()
Hope I helped, good luck.
No comments:
Post a Comment