void CheckIfForceWrite() { if (writeStream == null || contentLength < 0 || !InternalAllowBuffering) { return; } // This will write the POST/PUT if the write stream already has the expected // amount of bytes in it (ContentLength) (bug #77753). if (writeStream.WriteBufferLength == contentLength) { writeStream.WriteRequest(); } }
internal void SetWriteStream(WebConnectionStream stream) { if (aborted) { return; } writeStream = stream; if (bodyBuffer != null) { webHeaders.RemoveInternal("Transfer-Encoding"); contentLength = bodyBufferLength; writeStream.SendChunked = false; } SendRequestHeaders(); haveRequest = true; if (bodyBuffer != null) { // The body has been written and buffered. The request "user" // won't write it again, so we must do it. writeStream.Write(bodyBuffer, 0, bodyBufferLength); bodyBuffer = null; writeStream.Close(); } else if (method == "PUT" || method == "POST" || method == "OPTIONS") { if (getResponseCalled && !writeStream.RequestWritten) { writeStream.WriteRequest(); } } if (asyncWrite != null) { asyncWrite.SetCompleted(false, stream); asyncWrite.DoCallback(); asyncWrite = null; } }
void CheckIfForceWrite () { if (writeStream == null || writeStream.RequestWritten || !InternalAllowBuffering) return; #if NET_4_0 if (contentLength < 0 && writeStream.CanWrite == true && writeStream.WriteBufferLength <= 0) return; if (contentLength < 0 && writeStream.WriteBufferLength > 0) InternalContentLength = writeStream.WriteBufferLength; #else if (contentLength < 0 && writeStream.CanWrite == true) return; #endif // This will write the POST/PUT if the write stream already has the expected // amount of bytes in it (ContentLength) (bug #77753) or if the write stream // contains data and it has been closed already (xamarin bug #1512). if (writeStream.WriteBufferLength == contentLength || (contentLength == -1 && writeStream.CanWrite == false)) writeStream.WriteRequest (); }
internal void SetWriteStream (WebConnectionStream stream) { if (Aborted) return; writeStream = stream; if (bodyBuffer != null) { webHeaders.RemoveInternal ("Transfer-Encoding"); contentLength = bodyBufferLength; writeStream.SendChunked = false; } SendRequestHeaders (false); haveRequest = true; if (bodyBuffer != null) { // The body has been written and buffered. The request "user" // won't write it again, so we must do it. if (ntlm_auth_state != NtlmAuthState.Challenge) { writeStream.Write (bodyBuffer, 0, bodyBufferLength); bodyBuffer = null; writeStream.Close (); } } else if (method != "HEAD" && method != "GET" && method != "MKCOL" && method != "CONNECT" && method != "TRACE") { if (getResponseCalled && !writeStream.RequestWritten) writeStream.WriteRequest (); } if (asyncWrite != null) { asyncWrite.SetCompleted (false, stream); asyncWrite.DoCallback (); asyncWrite = null; } }