My outlook plugin sends large files over https. Currently I'm using Convert.ToBase64String() on the client side and Convert.FromBase64String() on the http handler on the IIS Side.
This has come to some performance issues, and also i'm also securing the data over SSL so i'm really asking if there's any way to convert a byte array over https without using encoding that will cost cpu performance on the recipient end.
My Client code:
string requestURL = "http://192.168.1.46/websvc/transfer.trn";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(requestURL);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
// Chunk(buffer) is converted to Base64 string that will be convert to Bytes on the handler.
string requestParameters = @"fileName=" + fileName + @"&secretKey=testKey=" + @"¤tChunk=" + i + @"&totalChunks=" + totalChunks + @"&smGuid=" + smGuid +
"&data=" + HttpUtility.UrlEncode(Convert.ToBase64String(bytes));
// finally whole request will be converted to bytes that will be transferred to HttpHandler
byte[] byteData = Encoding.UTF8.GetBytes(requestParameters);
request.ContentLength = byteData.Length;
Stream writer = request.GetRequestStream();
writer.Write(byteData, 0, byteData.Length);
writer.Close();
// here we will receive the response from HttpHandler
StreamReader stIn = new StreamReader(request.GetResponse().GetResponseStream());
string strResponse = stIn.ReadToEnd();
stIn.Close();
Server code where I have performance issues:
byte[] buffer = Convert.FromBase64String(context.Request.Form["data"]); //