private void ExecuteWriteThread()

in Scripts/Runtime/WitRequest.cs [672:711]


        private void ExecuteWriteThread(object obj)
        {
            bytesWritten = 0;
            Stream stream = (Stream) obj;

            try
            {
                while (isRequestStreamActive)
                {
                    FlushBuffer(stream);
                    Thread.Yield();
                }

                FlushBuffer(stream);
                stream.Close();
            }
            catch (ObjectDisposedException)
            {
                // Handling edge case where stream is closed remotely
                // This problem occurs when the Web server resets or closes the connection after
                // the client application sends the HTTP header.
                // https://support.microsoft.com/en-us/topic/fix-you-receive-a-system-objectdisposedexception-exception-when-you-try-to-access-a-stream-object-that-is-returned-by-the-endgetrequeststream-method-in-the-net-framework-2-0-bccefe57-0a61-517a-5d5f-2dce0cc63265
                Debug.LogWarning(
                    "Stream already disposed. It is likely the server reset the connection before streaming started.");
            }
            catch (IOException e)
            {
                Debug.LogWarning(e.Message);
            }
            catch (Exception e)
            {
                Debug.LogError(e);
            }

            if (requestRequiresBody && bytesWritten == 0)
            {
                Debug.LogWarning("Stream was closed with no data written. Aborting request.");
                AbortRequest();
            }
        }