internal void WriteRequest() { if (requestWritten) { return; } requestWritten = true; if (sendChunked || !allowBuffering || writeBuffer == null) { return; } byte[] buffer = writeBuffer.GetBuffer(); int num = (int)writeBuffer.Length; if (request.ContentLength != -1 && request.ContentLength < num) { nextReadCalled = true; cnc.Close(sendNext: true); throw new WebException("Specified Content-Length is less than the number of bytes to write", null, WebExceptionStatus.ServerProtocolViolation, null); } if (!headersSent) { string method = request.Method; int num2; switch (method) { default: num2 = ((method == "DELETE") ? 1 : 0); break; case "GET": case "CONNECT": case "HEAD": case "TRACE": num2 = 1; break; } if (num2 == 0) { request.InternalContentLength = num; } request.SendRequestHeaders(propagate_error: true); } WriteHeaders(); if (cnc.Data.StatusCode == 0 || cnc.Data.StatusCode == 100) { IAsyncResult result = null; if (num > 0) { result = cnc.BeginWrite(request, buffer, 0, num, null, null); } if (!initRead) { initRead = true; WebConnection.InitRead(cnc); } if (num > 0) { complete_request_written = cnc.EndWrite(request, result); } else { complete_request_written = true; } } }
internal void WriteRequest() { if (requestWritten) { return; } requestWritten = true; if (sendChunked) { return; } if (!allowBuffering || writeBuffer == null) { return; } byte [] bytes = writeBuffer.GetBuffer(); int length = (int)writeBuffer.Length; if (request.ContentLength != -1 && request.ContentLength < length) { nextReadCalled = true; cnc.Close(true); throw new WebException("Specified Content-Length is less than the number of bytes to write", null, WebExceptionStatus.ServerProtocolViolation, null); } if (!headersSent) { string method = request.Method; bool no_writestream = (method == "GET" || method == "CONNECT" || method == "HEAD" || method == "TRACE"); if (!no_writestream) { request.InternalContentLength = length; } request.SendRequestHeaders(true); } WriteHeaders(); if (cnc.Data.StatusCode != 0 && cnc.Data.StatusCode != 100) { return; } IAsyncResult result = null; if (length > 0) { result = cnc.BeginWrite(request, bytes, 0, length, null, null); } if (!initRead) { initRead = true; WebConnection.InitRead(cnc); } if (length > 0) { complete_request_written = cnc.EndWrite(request, result); } else { complete_request_written = true; } }
internal void WriteRequest() { if (requestWritten) { return; } if (sendChunked) { request.SendRequestHeaders(); requestWritten = true; return; } if (!allowBuffering || writeBuffer == null) { return; } byte [] bytes = writeBuffer.GetBuffer(); int length = (int)writeBuffer.Length; if (request.ContentLength != -1 && request.ContentLength < length) { throw new WebException("Specified Content-Length is less than the number of bytes to write", null, WebExceptionStatus.ServerProtocolViolation, null); } request.InternalContentLength = length; request.SendRequestHeaders(); requestWritten = true; if (!cnc.Write(headers, 0, headers.Length)) { throw new WebException("Error writing request.", null, WebExceptionStatus.SendFailure, null); } headersSent = true; if (cnc.Data.StatusCode != 0 && cnc.Data.StatusCode != 100) { return; } IAsyncResult result = null; if (length > 0) { result = cnc.BeginWrite(bytes, 0, length, null, null); } if (!initRead) { initRead = true; WebConnection.InitRead(cnc); } if (length > 0) { complete_request_written = cnc.EndWrite(result); } else { complete_request_written = true; } }