Files
Dec2017-Script-Dump/System/Net/WebConnectionStream.cs
T
2026-06-04 11:42:34 +02:00

1085 lines
26 KiB
C#

using System;
using System.IO;
using System.Net.Sockets;
using System.Text;
using System.Threading;
namespace System.Net
{
// Token: 0x02000265 RID: 613
internal class WebConnectionStream : Stream
{
// Token: 0x0600165F RID: 5727 RVA: 0x0004A5D0 File Offset: 0x000487D0
public WebConnectionStream(WebConnection cnc)
{
this.isRead = true;
this.pending = new ManualResetEvent(true);
this.request = cnc.Data.request;
this.read_timeout = this.request.ReadWriteTimeout;
this.write_timeout = this.read_timeout;
this.cnc = cnc;
string text = cnc.Data.Headers["Transfer-Encoding"];
bool flag = text != null && text.ToLower().IndexOf("chunked") != -1;
string text2 = cnc.Data.Headers["Content-Length"];
if (!flag && text2 != null && text2 != string.Empty)
{
try
{
this.contentLength = int.Parse(text2);
if (this.contentLength == 0 && !this.IsNtlmAuth())
{
this.ReadAll();
}
}
catch
{
this.contentLength = int.MaxValue;
}
}
else
{
this.contentLength = int.MaxValue;
}
}
// Token: 0x06001660 RID: 5728 RVA: 0x0004A708 File Offset: 0x00048908
public WebConnectionStream(WebConnection cnc, HttpWebRequest request)
{
this.read_timeout = request.ReadWriteTimeout;
this.write_timeout = this.read_timeout;
this.isRead = false;
this.cnc = cnc;
this.request = request;
this.allowBuffering = request.InternalAllowBuffering;
this.sendChunked = request.SendChunked;
if (this.sendChunked)
{
this.pending = new ManualResetEvent(true);
}
else if (this.allowBuffering)
{
this.writeBuffer = new MemoryStream();
}
}
// Token: 0x06001662 RID: 5730 RVA: 0x0004A7B8 File Offset: 0x000489B8
private bool IsNtlmAuth()
{
bool flag = this.request.Proxy != null && !this.request.Proxy.IsBypassed(this.request.Address);
string text = ((!flag) ? "WWW-Authenticate" : "Proxy-Authenticate");
string text2 = this.cnc.Data.Headers[text];
return text2 != null && text2.IndexOf("NTLM") != -1;
}
// Token: 0x06001663 RID: 5731 RVA: 0x0004A840 File Offset: 0x00048A40
internal void CheckResponseInBuffer()
{
if (this.contentLength > 0 && this.readBufferSize - this.readBufferOffset >= this.contentLength && !this.IsNtlmAuth())
{
this.ReadAll();
}
}
// Token: 0x1700072E RID: 1838
// (get) Token: 0x06001664 RID: 5732 RVA: 0x0004A878 File Offset: 0x00048A78
internal HttpWebRequest Request
{
get
{
return this.request;
}
}
// Token: 0x1700072F RID: 1839
// (get) Token: 0x06001665 RID: 5733 RVA: 0x0004A880 File Offset: 0x00048A80
internal WebConnection Connection
{
get
{
return this.cnc;
}
}
// Token: 0x17000730 RID: 1840
// (get) Token: 0x06001666 RID: 5734 RVA: 0x0004A888 File Offset: 0x00048A88
public override bool CanTimeout
{
get
{
return true;
}
}
// Token: 0x17000731 RID: 1841
// (get) Token: 0x06001667 RID: 5735 RVA: 0x0004A88C File Offset: 0x00048A8C
// (set) Token: 0x06001668 RID: 5736 RVA: 0x0004A894 File Offset: 0x00048A94
public override int ReadTimeout
{
get
{
return this.read_timeout;
}
set
{
if (value < -1)
{
throw new ArgumentOutOfRangeException("value");
}
this.read_timeout = value;
}
}
// Token: 0x17000732 RID: 1842
// (get) Token: 0x06001669 RID: 5737 RVA: 0x0004A8B0 File Offset: 0x00048AB0
// (set) Token: 0x0600166A RID: 5738 RVA: 0x0004A8B8 File Offset: 0x00048AB8
public override int WriteTimeout
{
get
{
return this.write_timeout;
}
set
{
if (value < -1)
{
throw new ArgumentOutOfRangeException("value");
}
this.write_timeout = value;
}
}
// Token: 0x17000733 RID: 1843
// (get) Token: 0x0600166B RID: 5739 RVA: 0x0004A8D4 File Offset: 0x00048AD4
internal bool CompleteRequestWritten
{
get
{
return this.complete_request_written;
}
}
// Token: 0x17000734 RID: 1844
// (set) Token: 0x0600166C RID: 5740 RVA: 0x0004A8DC File Offset: 0x00048ADC
internal bool SendChunked
{
set
{
this.sendChunked = value;
}
}
// Token: 0x17000735 RID: 1845
// (set) Token: 0x0600166D RID: 5741 RVA: 0x0004A8E8 File Offset: 0x00048AE8
internal byte[] ReadBuffer
{
set
{
this.readBuffer = value;
}
}
// Token: 0x17000736 RID: 1846
// (set) Token: 0x0600166E RID: 5742 RVA: 0x0004A8F4 File Offset: 0x00048AF4
internal int ReadBufferOffset
{
set
{
this.readBufferOffset = value;
}
}
// Token: 0x17000737 RID: 1847
// (set) Token: 0x0600166F RID: 5743 RVA: 0x0004A900 File Offset: 0x00048B00
internal int ReadBufferSize
{
set
{
this.readBufferSize = value;
}
}
// Token: 0x17000738 RID: 1848
// (get) Token: 0x06001670 RID: 5744 RVA: 0x0004A90C File Offset: 0x00048B0C
internal byte[] WriteBuffer
{
get
{
return this.writeBuffer.GetBuffer();
}
}
// Token: 0x17000739 RID: 1849
// (get) Token: 0x06001671 RID: 5745 RVA: 0x0004A91C File Offset: 0x00048B1C
internal int WriteBufferLength
{
get
{
return (this.writeBuffer == null) ? (-1) : ((int)this.writeBuffer.Length);
}
}
// Token: 0x06001672 RID: 5746 RVA: 0x0004A93C File Offset: 0x00048B3C
internal void ForceCompletion()
{
if (!this.nextReadCalled)
{
if (this.contentLength == 2147483647)
{
this.contentLength = 0;
}
this.nextReadCalled = true;
this.cnc.NextRead();
}
}
// Token: 0x06001673 RID: 5747 RVA: 0x0004A980 File Offset: 0x00048B80
internal void CheckComplete()
{
if (!this.nextReadCalled && this.readBufferSize - this.readBufferOffset == this.contentLength)
{
this.nextReadCalled = true;
this.cnc.NextRead();
}
}
// Token: 0x06001674 RID: 5748 RVA: 0x0004A9C4 File Offset: 0x00048BC4
internal void ReadAll()
{
if (!this.isRead || this.read_eof || this.totalRead >= this.contentLength || this.nextReadCalled)
{
if (this.isRead && !this.nextReadCalled)
{
this.nextReadCalled = true;
this.cnc.NextRead();
}
return;
}
this.pending.WaitOne();
object obj = this.locker;
lock (obj)
{
if (this.totalRead >= this.contentLength)
{
return;
}
int num = this.readBufferSize - this.readBufferOffset;
byte[] array2;
int num3;
if (this.contentLength == 2147483647)
{
MemoryStream memoryStream = new MemoryStream();
byte[] array = null;
if (this.readBuffer != null && num > 0)
{
memoryStream.Write(this.readBuffer, this.readBufferOffset, num);
if (this.readBufferSize >= 8192)
{
array = this.readBuffer;
}
}
if (array == null)
{
array = new byte[8192];
}
int num2;
while ((num2 = this.cnc.Read(this.request, array, 0, array.Length)) != 0)
{
memoryStream.Write(array, 0, num2);
}
array2 = memoryStream.GetBuffer();
num3 = (int)memoryStream.Length;
this.contentLength = num3;
}
else
{
num3 = this.contentLength - this.totalRead;
array2 = new byte[num3];
if (this.readBuffer != null && num > 0)
{
if (num > num3)
{
num = num3;
}
Buffer.BlockCopy(this.readBuffer, this.readBufferOffset, array2, 0, num);
}
int num4 = num3 - num;
int num5 = -1;
while (num4 > 0 && num5 != 0)
{
num5 = this.cnc.Read(this.request, array2, num, num4);
num4 -= num5;
num += num5;
}
}
this.readBuffer = array2;
this.readBufferOffset = 0;
this.readBufferSize = num3;
this.totalRead = 0;
this.nextReadCalled = true;
}
this.cnc.NextRead();
}
// Token: 0x06001675 RID: 5749 RVA: 0x0004AC00 File Offset: 0x00048E00
private void WriteCallbackWrapper(IAsyncResult r)
{
WebAsyncResult webAsyncResult = r as WebAsyncResult;
if (webAsyncResult != null && webAsyncResult.AsyncWriteAll)
{
return;
}
if (r.AsyncState != null)
{
webAsyncResult = (WebAsyncResult)r.AsyncState;
webAsyncResult.InnerAsyncResult = r;
webAsyncResult.DoCallback();
}
else
{
this.EndWrite(r);
}
}
// Token: 0x06001676 RID: 5750 RVA: 0x0004AC58 File Offset: 0x00048E58
private void ReadCallbackWrapper(IAsyncResult r)
{
if (r.AsyncState != null)
{
WebAsyncResult webAsyncResult = (WebAsyncResult)r.AsyncState;
webAsyncResult.InnerAsyncResult = r;
webAsyncResult.DoCallback();
}
else
{
this.EndRead(r);
}
}
// Token: 0x06001677 RID: 5751 RVA: 0x0004AC98 File Offset: 0x00048E98
public override int Read(byte[] buffer, int offset, int size)
{
AsyncCallback asyncCallback = new AsyncCallback(this.ReadCallbackWrapper);
WebAsyncResult webAsyncResult = (WebAsyncResult)this.BeginRead(buffer, offset, size, asyncCallback, null);
if (!webAsyncResult.IsCompleted && !webAsyncResult.WaitUntilComplete(this.ReadTimeout, false))
{
this.nextReadCalled = true;
this.cnc.Close(true);
throw new WebException("The operation has timed out.", WebExceptionStatus.Timeout);
}
return this.EndRead(webAsyncResult);
}
// Token: 0x06001678 RID: 5752 RVA: 0x0004AD08 File Offset: 0x00048F08
public override IAsyncResult BeginRead(byte[] buffer, int offset, int size, AsyncCallback cb, object state)
{
if (!this.isRead)
{
throw new NotSupportedException("this stream does not allow reading");
}
if (buffer == null)
{
throw new ArgumentNullException("buffer");
}
int num = buffer.Length;
if (offset < 0 || num < offset)
{
throw new ArgumentOutOfRangeException("offset");
}
if (size < 0 || num - offset < size)
{
throw new ArgumentOutOfRangeException("size");
}
object obj = this.locker;
lock (obj)
{
this.pendingReads++;
this.pending.Reset();
}
WebAsyncResult webAsyncResult = new WebAsyncResult(cb, state, buffer, offset, size);
if (this.totalRead >= this.contentLength)
{
webAsyncResult.SetCompleted(true, -1);
webAsyncResult.DoCallback();
return webAsyncResult;
}
int num2 = this.readBufferSize - this.readBufferOffset;
if (num2 > 0)
{
int num3 = ((num2 <= size) ? num2 : size);
Buffer.BlockCopy(this.readBuffer, this.readBufferOffset, buffer, offset, num3);
this.readBufferOffset += num3;
offset += num3;
size -= num3;
this.totalRead += num3;
if (size == 0 || this.totalRead >= this.contentLength)
{
webAsyncResult.SetCompleted(true, num3);
webAsyncResult.DoCallback();
return webAsyncResult;
}
webAsyncResult.NBytes = num3;
}
if (cb != null)
{
cb = new AsyncCallback(this.ReadCallbackWrapper);
}
if (this.contentLength != 2147483647 && this.contentLength - this.totalRead < size)
{
size = this.contentLength - this.totalRead;
}
if (!this.read_eof)
{
webAsyncResult.InnerAsyncResult = this.cnc.BeginRead(this.request, buffer, offset, size, cb, webAsyncResult);
}
else
{
webAsyncResult.SetCompleted(true, webAsyncResult.NBytes);
webAsyncResult.DoCallback();
}
return webAsyncResult;
}
// Token: 0x06001679 RID: 5753 RVA: 0x0004AF10 File Offset: 0x00049110
public override int EndRead(IAsyncResult r)
{
WebAsyncResult webAsyncResult = (WebAsyncResult)r;
if (webAsyncResult.EndCalled)
{
int nbytes = webAsyncResult.NBytes;
return (nbytes < 0) ? 0 : nbytes;
}
webAsyncResult.EndCalled = true;
if (!webAsyncResult.IsCompleted)
{
int num = -1;
try
{
num = this.cnc.EndRead(this.request, webAsyncResult);
}
catch (Exception ex)
{
object obj = this.locker;
lock (obj)
{
this.pendingReads--;
if (this.pendingReads == 0)
{
this.pending.Set();
}
}
this.nextReadCalled = true;
this.cnc.Close(true);
webAsyncResult.SetCompleted(false, ex);
webAsyncResult.DoCallback();
throw;
}
if (num < 0)
{
num = 0;
this.read_eof = true;
}
this.totalRead += num;
webAsyncResult.SetCompleted(false, num + webAsyncResult.NBytes);
webAsyncResult.DoCallback();
if (num == 0)
{
this.contentLength = this.totalRead;
}
}
object obj2 = this.locker;
lock (obj2)
{
this.pendingReads--;
if (this.pendingReads == 0)
{
this.pending.Set();
}
}
if (this.totalRead >= this.contentLength && !this.nextReadCalled)
{
this.ReadAll();
}
int nbytes2 = webAsyncResult.NBytes;
return (nbytes2 < 0) ? 0 : nbytes2;
}
// Token: 0x0600167A RID: 5754 RVA: 0x0004B0E8 File Offset: 0x000492E8
private void WriteRequestAsyncCB(IAsyncResult r)
{
WebAsyncResult webAsyncResult = (WebAsyncResult)r.AsyncState;
try
{
this.cnc.EndWrite2(this.request, r);
webAsyncResult.SetCompleted(false, 0);
if (!this.initRead)
{
this.initRead = true;
WebConnection.InitRead(this.cnc);
}
}
catch (Exception ex)
{
this.KillBuffer();
this.nextReadCalled = true;
this.cnc.Close(true);
if (ex is global::System.Net.Sockets.SocketException)
{
ex = new IOException("Error writing request", ex);
}
webAsyncResult.SetCompleted(false, ex);
}
this.complete_request_written = true;
webAsyncResult.DoCallback();
}
// Token: 0x0600167B RID: 5755 RVA: 0x0004B1A4 File Offset: 0x000493A4
public override IAsyncResult BeginWrite(byte[] buffer, int offset, int size, AsyncCallback cb, object state)
{
if (this.request.Aborted)
{
throw new WebException("The request was canceled.", null, WebExceptionStatus.RequestCanceled);
}
if (this.isRead)
{
throw new NotSupportedException("this stream does not allow writing");
}
if (buffer == null)
{
throw new ArgumentNullException("buffer");
}
int num = buffer.Length;
if (offset < 0 || num < offset)
{
throw new ArgumentOutOfRangeException("offset");
}
if (size < 0 || num - offset < size)
{
throw new ArgumentOutOfRangeException("size");
}
if (this.sendChunked)
{
object obj = this.locker;
lock (obj)
{
this.pendingWrites++;
this.pending.Reset();
}
}
WebAsyncResult webAsyncResult = new WebAsyncResult(cb, state);
if (!this.sendChunked)
{
this.CheckWriteOverflow(this.request.ContentLength, this.totalWritten, (long)size);
}
if (this.allowBuffering && !this.sendChunked)
{
if (this.writeBuffer == null)
{
this.writeBuffer = new MemoryStream();
}
this.writeBuffer.Write(buffer, offset, size);
this.totalWritten += (long)size;
if (this.request.ContentLength > 0L && this.totalWritten == this.request.ContentLength)
{
try
{
webAsyncResult.AsyncWriteAll = true;
webAsyncResult.InnerAsyncResult = this.WriteRequestAsync(new AsyncCallback(this.WriteRequestAsyncCB), webAsyncResult);
if (webAsyncResult.InnerAsyncResult == null)
{
if (!webAsyncResult.IsCompleted)
{
webAsyncResult.SetCompleted(true, 0);
}
webAsyncResult.DoCallback();
}
}
catch (Exception ex)
{
webAsyncResult.SetCompleted(true, ex);
webAsyncResult.DoCallback();
}
}
else
{
webAsyncResult.SetCompleted(true, 0);
webAsyncResult.DoCallback();
}
return webAsyncResult;
}
AsyncCallback asyncCallback = null;
if (cb != null)
{
asyncCallback = new AsyncCallback(this.WriteCallbackWrapper);
}
if (this.sendChunked)
{
this.WriteRequest();
string text = string.Format("{0:X}\r\n", size);
byte[] bytes = Encoding.ASCII.GetBytes(text);
int num2 = 2 + size + bytes.Length;
byte[] array = new byte[num2];
Buffer.BlockCopy(bytes, 0, array, 0, bytes.Length);
Buffer.BlockCopy(buffer, offset, array, bytes.Length, size);
Buffer.BlockCopy(WebConnectionStream.crlf, 0, array, bytes.Length + size, WebConnectionStream.crlf.Length);
buffer = array;
offset = 0;
size = num2;
}
webAsyncResult.InnerAsyncResult = this.cnc.BeginWrite(this.request, buffer, offset, size, asyncCallback, webAsyncResult);
this.totalWritten += (long)size;
return webAsyncResult;
}
// Token: 0x0600167C RID: 5756 RVA: 0x0004B47C File Offset: 0x0004967C
private void CheckWriteOverflow(long contentLength, long totalWritten, long size)
{
if (contentLength == -1L)
{
return;
}
long num = contentLength - totalWritten;
if (size > num)
{
this.KillBuffer();
this.nextReadCalled = true;
this.cnc.Close(true);
throw new ProtocolViolationException("The number of bytes to be written is greater than the specified ContentLength.");
}
}
// Token: 0x0600167D RID: 5757 RVA: 0x0004B4C4 File Offset: 0x000496C4
public override void EndWrite(IAsyncResult r)
{
if (r == null)
{
throw new ArgumentNullException("r");
}
WebAsyncResult webAsyncResult = r as WebAsyncResult;
if (webAsyncResult == null)
{
throw new ArgumentException("Invalid IAsyncResult");
}
if (webAsyncResult.EndCalled)
{
return;
}
webAsyncResult.EndCalled = true;
if (webAsyncResult.AsyncWriteAll)
{
webAsyncResult.WaitUntilComplete();
if (webAsyncResult.GotException)
{
throw webAsyncResult.Exception;
}
return;
}
else
{
if (this.allowBuffering && !this.sendChunked)
{
return;
}
if (webAsyncResult.GotException)
{
throw webAsyncResult.Exception;
}
try
{
this.cnc.EndWrite2(this.request, webAsyncResult.InnerAsyncResult);
webAsyncResult.SetCompleted(false, 0);
webAsyncResult.DoCallback();
}
catch (Exception ex)
{
webAsyncResult.SetCompleted(false, ex);
webAsyncResult.DoCallback();
throw;
}
finally
{
if (this.sendChunked)
{
object obj = this.locker;
lock (obj)
{
this.pendingWrites--;
if (this.pendingWrites == 0)
{
this.pending.Set();
}
}
}
}
return;
}
}
// Token: 0x0600167E RID: 5758 RVA: 0x0004B630 File Offset: 0x00049830
public override void Write(byte[] buffer, int offset, int size)
{
AsyncCallback asyncCallback = new AsyncCallback(this.WriteCallbackWrapper);
WebAsyncResult webAsyncResult = (WebAsyncResult)this.BeginWrite(buffer, offset, size, asyncCallback, null);
if (!webAsyncResult.IsCompleted && !webAsyncResult.WaitUntilComplete(this.WriteTimeout, false))
{
this.KillBuffer();
this.nextReadCalled = true;
this.cnc.Close(true);
throw new IOException("Write timed out.");
}
this.EndWrite(webAsyncResult);
}
// Token: 0x0600167F RID: 5759 RVA: 0x0004B6A4 File Offset: 0x000498A4
public override void Flush()
{
}
// Token: 0x06001680 RID: 5760 RVA: 0x0004B6A8 File Offset: 0x000498A8
internal void SetHeaders(byte[] buffer)
{
if (this.headersSent)
{
return;
}
this.headers = buffer;
long num = this.request.ContentLength;
string method = this.request.Method;
bool flag = method == "GET" || method == "CONNECT" || method == "HEAD" || method == "TRACE" || method == "DELETE";
if (this.sendChunked || num > -1L || flag)
{
this.WriteHeaders();
if (!this.initRead)
{
this.initRead = true;
WebConnection.InitRead(this.cnc);
}
if (!this.sendChunked && num == 0L)
{
this.requestWritten = true;
}
}
}
// Token: 0x1700073A RID: 1850
// (get) Token: 0x06001681 RID: 5761 RVA: 0x0004B784 File Offset: 0x00049984
internal bool RequestWritten
{
get
{
return this.requestWritten;
}
}
// Token: 0x06001682 RID: 5762 RVA: 0x0004B78C File Offset: 0x0004998C
private IAsyncResult WriteRequestAsync(AsyncCallback cb, object state)
{
this.requestWritten = true;
byte[] buffer = this.writeBuffer.GetBuffer();
int num = (int)this.writeBuffer.Length;
IAsyncResult asyncResult2;
if (num > 0)
{
IAsyncResult asyncResult = this.cnc.BeginWrite(this.request, buffer, 0, num, cb, state);
asyncResult2 = asyncResult;
}
else
{
asyncResult2 = null;
}
return asyncResult2;
}
// Token: 0x06001683 RID: 5763 RVA: 0x0004B7E0 File Offset: 0x000499E0
private void WriteHeaders()
{
if (this.headersSent)
{
return;
}
this.headersSent = true;
string text = null;
if (!this.cnc.Write(this.request, this.headers, 0, this.headers.Length, ref text))
{
throw new WebException("Error writing request: " + text, null, WebExceptionStatus.SendFailure, null);
}
}
// Token: 0x06001684 RID: 5764 RVA: 0x0004B840 File Offset: 0x00049A40
internal void WriteRequest()
{
if (this.requestWritten)
{
return;
}
this.requestWritten = true;
if (this.sendChunked)
{
return;
}
if (!this.allowBuffering || this.writeBuffer == null)
{
return;
}
byte[] buffer = this.writeBuffer.GetBuffer();
int num = (int)this.writeBuffer.Length;
if (this.request.ContentLength != -1L && this.request.ContentLength < (long)num)
{
this.nextReadCalled = true;
this.cnc.Close(true);
throw new WebException("Specified Content-Length is less than the number of bytes to write", null, WebExceptionStatus.ServerProtocolViolation, null);
}
if (!this.headersSent)
{
string method = this.request.Method;
if (!(method == "GET") && !(method == "CONNECT") && !(method == "HEAD") && !(method == "TRACE") && !(method == "DELETE"))
{
this.request.InternalContentLength = (long)num;
}
this.request.SendRequestHeaders(true);
}
this.WriteHeaders();
if (this.cnc.Data.StatusCode != 0 && this.cnc.Data.StatusCode != 100)
{
return;
}
IAsyncResult asyncResult = null;
if (num > 0)
{
asyncResult = this.cnc.BeginWrite(this.request, buffer, 0, num, null, null);
}
if (!this.initRead)
{
this.initRead = true;
WebConnection.InitRead(this.cnc);
}
if (num > 0)
{
this.complete_request_written = this.cnc.EndWrite(this.request, asyncResult);
}
else
{
this.complete_request_written = true;
}
}
// Token: 0x06001685 RID: 5765 RVA: 0x0004BA08 File Offset: 0x00049C08
internal void InternalClose()
{
this.disposed = true;
}
// Token: 0x06001686 RID: 5766 RVA: 0x0004BA14 File Offset: 0x00049C14
public override void Close()
{
if (this.sendChunked)
{
if (this.disposed)
{
return;
}
this.disposed = true;
this.pending.WaitOne();
byte[] bytes = Encoding.ASCII.GetBytes("0\r\n\r\n");
string text = null;
this.cnc.Write(this.request, bytes, 0, bytes.Length, ref text);
return;
}
else
{
if (this.isRead)
{
if (!this.nextReadCalled)
{
this.CheckComplete();
if (!this.nextReadCalled)
{
this.nextReadCalled = true;
this.cnc.Close(true);
}
}
return;
}
if (!this.allowBuffering)
{
this.complete_request_written = true;
if (!this.initRead)
{
this.initRead = true;
WebConnection.InitRead(this.cnc);
}
return;
}
if (this.disposed || this.requestWritten)
{
return;
}
long num = this.request.ContentLength;
if (!this.sendChunked && num != -1L && this.totalWritten != num)
{
IOException ex = new IOException("Cannot close the stream until all bytes are written");
this.nextReadCalled = true;
this.cnc.Close(true);
throw new WebException("Request was cancelled.", ex, WebExceptionStatus.RequestCanceled);
}
this.WriteRequest();
this.disposed = true;
return;
}
}
// Token: 0x06001687 RID: 5767 RVA: 0x0004BB5C File Offset: 0x00049D5C
internal void KillBuffer()
{
this.writeBuffer = null;
}
// Token: 0x06001688 RID: 5768 RVA: 0x0004BB68 File Offset: 0x00049D68
public override long Seek(long a, SeekOrigin b)
{
throw new NotSupportedException();
}
// Token: 0x06001689 RID: 5769 RVA: 0x0004BB70 File Offset: 0x00049D70
public override void SetLength(long a)
{
throw new NotSupportedException();
}
// Token: 0x1700073B RID: 1851
// (get) Token: 0x0600168A RID: 5770 RVA: 0x0004BB78 File Offset: 0x00049D78
public override bool CanSeek
{
get
{
return false;
}
}
// Token: 0x1700073C RID: 1852
// (get) Token: 0x0600168B RID: 5771 RVA: 0x0004BB7C File Offset: 0x00049D7C
public override bool CanRead
{
get
{
return !this.disposed && this.isRead;
}
}
// Token: 0x1700073D RID: 1853
// (get) Token: 0x0600168C RID: 5772 RVA: 0x0004BB94 File Offset: 0x00049D94
public override bool CanWrite
{
get
{
return !this.disposed && !this.isRead;
}
}
// Token: 0x1700073E RID: 1854
// (get) Token: 0x0600168D RID: 5773 RVA: 0x0004BBB0 File Offset: 0x00049DB0
public override long Length
{
get
{
throw new NotSupportedException();
}
}
// Token: 0x1700073F RID: 1855
// (get) Token: 0x0600168E RID: 5774 RVA: 0x0004BBB8 File Offset: 0x00049DB8
// (set) Token: 0x0600168F RID: 5775 RVA: 0x0004BBC0 File Offset: 0x00049DC0
public override long Position
{
get
{
throw new NotSupportedException();
}
set
{
throw new NotSupportedException();
}
}
// Token: 0x0400123B RID: 4667
private static byte[] crlf = new byte[] { 13, 10 };
// Token: 0x0400123C RID: 4668
private bool isRead;
// Token: 0x0400123D RID: 4669
private WebConnection cnc;
// Token: 0x0400123E RID: 4670
private HttpWebRequest request;
// Token: 0x0400123F RID: 4671
private byte[] readBuffer;
// Token: 0x04001240 RID: 4672
private int readBufferOffset;
// Token: 0x04001241 RID: 4673
private int readBufferSize;
// Token: 0x04001242 RID: 4674
private int contentLength;
// Token: 0x04001243 RID: 4675
private int totalRead;
// Token: 0x04001244 RID: 4676
private long totalWritten;
// Token: 0x04001245 RID: 4677
private bool nextReadCalled;
// Token: 0x04001246 RID: 4678
private int pendingReads;
// Token: 0x04001247 RID: 4679
private int pendingWrites;
// Token: 0x04001248 RID: 4680
private ManualResetEvent pending;
// Token: 0x04001249 RID: 4681
private bool allowBuffering;
// Token: 0x0400124A RID: 4682
private bool sendChunked;
// Token: 0x0400124B RID: 4683
private MemoryStream writeBuffer;
// Token: 0x0400124C RID: 4684
private bool requestWritten;
// Token: 0x0400124D RID: 4685
private byte[] headers;
// Token: 0x0400124E RID: 4686
private bool disposed;
// Token: 0x0400124F RID: 4687
private bool headersSent;
// Token: 0x04001250 RID: 4688
private object locker = new object();
// Token: 0x04001251 RID: 4689
private bool initRead;
// Token: 0x04001252 RID: 4690
private bool read_eof;
// Token: 0x04001253 RID: 4691
private bool complete_request_written;
// Token: 0x04001254 RID: 4692
private int read_timeout;
// Token: 0x04001255 RID: 4693
private int write_timeout;
}
}