0
Answer

Httpwebrequest - get final response after status code 102

Besik Betchvaia

Besik Betchvaia

10y
1.1k
1
I have encountered following problem. In my application I do simple Httpwebrequest to a server with "POST" method. As a response I got status code 102 ("Processing"). My question is, how to wait and get final response from the server.

Dictionary<string, string> dicForm = new Dictionary<string, string>();
            dicForm.Add("DVdevsel", counterNum);
            string boundary = "---------------------------" + genBoundary(14);
            byte[] data = this.genFormData(dicForm, boundary);

            HttpWebRequest myHttpWebRequest = (HttpWebRequest)HttpWebRequest.Create(url);
            myHttpWebRequest.Method = "POST";
            myHttpWebRequest.KeepAlive = false;
            myHttpWebRequest.ContentType = "multipart/form-data; boundary=" + boundary;
            myHttpWebRequest.ContentLength = data.Length;


            Stream requestStream = myHttpWebRequest.GetRequestStream();
            requestStream.Write(data, 0, data.Length);
            requestStream.Close();

            HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
            Stream responseStream = myHttpWebResponse.GetResponseStream();

            StreamReader myStreamReader = new StreamReader(responseStream, Encoding.Default);

            string pageContent = myStreamReader.ReadToEnd();

            myStreamReader.Close();
            responseStream.Close();

            myHttpWebResponse.Close();