AndyH79
asked on
Need to set up a url stream with the content encoding property set
I need to be able to use some type of stream that allows me to set the Content-Encoding = gzip. The HttpWebRequest allows me to set a Transfer-Encoding which I think is when each buffer is compressed individually. My implementation is where the whole file is compressed and the buffer is reading portions of the compressed file. If someone could let me know the correct object I should be using I would appreciate it. Also how to set the user and password information since I don't see that as an obvious available option for the HttpWebRequest object.
static private void SendFileUsingWebRequest(re f CClient Client)
{
string url = "https://xxx.xxxx.xxx/tools/services/rest/v1/importreadingdata?MessageFormat=MeasurementsLite.Meter";
HttpWebRequest request = (HttpWebRequest)WebRequest .Create(ur l);
request.Method = "POST";
request.ContentType = "application/x-protobuf";
Stream input = File.Open(Client.compresse dFilePath, FileMode.O pen);
Stream output = request.GetRequestStream() ;
byte[] buffer = new byte[8096];
int read = -1;
while (read != 0)
{
read = input.Read(buffer, 0, 8096);
if (read != 0)
{
output.Write(buffer, 0, read);
}
}
input.Close();
output.Close();
WebResponse response = request.GetResponse();
Client.responseCode = response.ToString();
}
static private void SendFileUsingWebRequest(re
{
string url = "https://xxx.xxxx.xxx/tools/services/rest/v1/importreadingdata?MessageFormat=MeasurementsLite.Meter";
HttpWebRequest request = (HttpWebRequest)WebRequest
request.Method = "POST";
request.ContentType = "application/x-protobuf";
Stream input = File.Open(Client.compresse
Stream output = request.GetRequestStream()
byte[] buffer = new byte[8096];
int read = -1;
while (read != 0)
{
read = input.Read(buffer, 0, 8096);
if (read != 0)
{
output.Write(buffer, 0, read);
}
}
input.Close();
output.Close();
WebResponse response = request.GetResponse();
Client.responseCode = response.ToString();
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.