275 lines
6.8 KiB
C#
275 lines
6.8 KiB
C#
using System;
|
|
using System.IO;
|
|
using System.Runtime.InteropServices;
|
|
|
|
namespace System.Net
|
|
{
|
|
// Token: 0x02000250 RID: 592
|
|
internal class RequestStream : Stream
|
|
{
|
|
// Token: 0x060014F2 RID: 5362 RVA: 0x00042FF8 File Offset: 0x000411F8
|
|
internal RequestStream(Stream stream, byte[] buffer, int offset, int length)
|
|
: this(stream, buffer, offset, length, -1L)
|
|
{
|
|
}
|
|
|
|
// Token: 0x060014F3 RID: 5363 RVA: 0x00043008 File Offset: 0x00041208
|
|
internal RequestStream(Stream stream, byte[] buffer, int offset, int length, long contentlength)
|
|
{
|
|
this.stream = stream;
|
|
this.buffer = buffer;
|
|
this.offset = offset;
|
|
this.length = length;
|
|
this.remaining_body = contentlength;
|
|
}
|
|
|
|
// Token: 0x170006D7 RID: 1751
|
|
// (get) Token: 0x060014F4 RID: 5364 RVA: 0x00043038 File Offset: 0x00041238
|
|
public override bool CanRead
|
|
{
|
|
get
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
|
|
// Token: 0x170006D8 RID: 1752
|
|
// (get) Token: 0x060014F5 RID: 5365 RVA: 0x0004303C File Offset: 0x0004123C
|
|
public override bool CanSeek
|
|
{
|
|
get
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
// Token: 0x170006D9 RID: 1753
|
|
// (get) Token: 0x060014F6 RID: 5366 RVA: 0x00043040 File Offset: 0x00041240
|
|
public override bool CanWrite
|
|
{
|
|
get
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
// Token: 0x170006DA RID: 1754
|
|
// (get) Token: 0x060014F7 RID: 5367 RVA: 0x00043044 File Offset: 0x00041244
|
|
public override long Length
|
|
{
|
|
get
|
|
{
|
|
throw new NotSupportedException();
|
|
}
|
|
}
|
|
|
|
// Token: 0x170006DB RID: 1755
|
|
// (get) Token: 0x060014F8 RID: 5368 RVA: 0x0004304C File Offset: 0x0004124C
|
|
// (set) Token: 0x060014F9 RID: 5369 RVA: 0x00043054 File Offset: 0x00041254
|
|
public override long Position
|
|
{
|
|
get
|
|
{
|
|
throw new NotSupportedException();
|
|
}
|
|
set
|
|
{
|
|
throw new NotSupportedException();
|
|
}
|
|
}
|
|
|
|
// Token: 0x060014FA RID: 5370 RVA: 0x0004305C File Offset: 0x0004125C
|
|
public override void Close()
|
|
{
|
|
this.disposed = true;
|
|
}
|
|
|
|
// Token: 0x060014FB RID: 5371 RVA: 0x00043068 File Offset: 0x00041268
|
|
public override void Flush()
|
|
{
|
|
}
|
|
|
|
// Token: 0x060014FC RID: 5372 RVA: 0x0004306C File Offset: 0x0004126C
|
|
private int FillFromBuffer(byte[] buffer, int off, int count)
|
|
{
|
|
if (buffer == null)
|
|
{
|
|
throw new ArgumentNullException("buffer");
|
|
}
|
|
if (off < 0)
|
|
{
|
|
throw new ArgumentOutOfRangeException("offset", "< 0");
|
|
}
|
|
if (count < 0)
|
|
{
|
|
throw new ArgumentOutOfRangeException("count", "< 0");
|
|
}
|
|
int num = buffer.Length;
|
|
if (off > num)
|
|
{
|
|
throw new ArgumentException("destination offset is beyond array size");
|
|
}
|
|
if (off > num - count)
|
|
{
|
|
throw new ArgumentException("Reading would overrun buffer");
|
|
}
|
|
if (this.remaining_body == 0L)
|
|
{
|
|
return -1;
|
|
}
|
|
if (this.length == 0)
|
|
{
|
|
return 0;
|
|
}
|
|
int num2 = Math.Min(this.length, count);
|
|
if (this.remaining_body > 0L)
|
|
{
|
|
num2 = (int)Math.Min((long)num2, this.remaining_body);
|
|
}
|
|
if (this.offset > this.buffer.Length - num2)
|
|
{
|
|
num2 = Math.Min(num2, this.buffer.Length - this.offset);
|
|
}
|
|
if (num2 == 0)
|
|
{
|
|
return 0;
|
|
}
|
|
Buffer.BlockCopy(this.buffer, this.offset, buffer, off, num2);
|
|
this.offset += num2;
|
|
this.length -= num2;
|
|
if (this.remaining_body > 0L)
|
|
{
|
|
this.remaining_body -= (long)num2;
|
|
}
|
|
return num2;
|
|
}
|
|
|
|
// Token: 0x060014FD RID: 5373 RVA: 0x000431A8 File Offset: 0x000413A8
|
|
public override int Read([In] [Out] byte[] buffer, int offset, int count)
|
|
{
|
|
if (this.disposed)
|
|
{
|
|
throw new ObjectDisposedException(typeof(RequestStream).ToString());
|
|
}
|
|
int num = this.FillFromBuffer(buffer, offset, count);
|
|
if (num == -1)
|
|
{
|
|
return 0;
|
|
}
|
|
if (num > 0)
|
|
{
|
|
return num;
|
|
}
|
|
num = this.stream.Read(buffer, offset, count);
|
|
if (num > 0 && this.remaining_body > 0L)
|
|
{
|
|
this.remaining_body -= (long)num;
|
|
}
|
|
return num;
|
|
}
|
|
|
|
// Token: 0x060014FE RID: 5374 RVA: 0x00043224 File Offset: 0x00041424
|
|
public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback cback, object state)
|
|
{
|
|
if (this.disposed)
|
|
{
|
|
throw new ObjectDisposedException(typeof(RequestStream).ToString());
|
|
}
|
|
int num = this.FillFromBuffer(buffer, offset, count);
|
|
if (num > 0 || num == -1)
|
|
{
|
|
HttpStreamAsyncResult httpStreamAsyncResult = new HttpStreamAsyncResult();
|
|
httpStreamAsyncResult.Buffer = buffer;
|
|
httpStreamAsyncResult.Offset = offset;
|
|
httpStreamAsyncResult.Count = count;
|
|
httpStreamAsyncResult.Callback = cback;
|
|
httpStreamAsyncResult.State = state;
|
|
httpStreamAsyncResult.SynchRead = num;
|
|
httpStreamAsyncResult.Complete();
|
|
return httpStreamAsyncResult;
|
|
}
|
|
if (this.remaining_body >= 0L && (long)count > this.remaining_body)
|
|
{
|
|
count = (int)Math.Min(2147483647L, this.remaining_body);
|
|
}
|
|
return this.stream.BeginRead(buffer, offset, count, cback, state);
|
|
}
|
|
|
|
// Token: 0x060014FF RID: 5375 RVA: 0x000432E4 File Offset: 0x000414E4
|
|
public override int EndRead(IAsyncResult ares)
|
|
{
|
|
if (this.disposed)
|
|
{
|
|
throw new ObjectDisposedException(typeof(RequestStream).ToString());
|
|
}
|
|
if (ares == null)
|
|
{
|
|
throw new ArgumentNullException("async_result");
|
|
}
|
|
if (ares is HttpStreamAsyncResult)
|
|
{
|
|
HttpStreamAsyncResult httpStreamAsyncResult = (HttpStreamAsyncResult)ares;
|
|
if (!ares.IsCompleted)
|
|
{
|
|
ares.AsyncWaitHandle.WaitOne();
|
|
}
|
|
return httpStreamAsyncResult.SynchRead;
|
|
}
|
|
int num = this.stream.EndRead(ares);
|
|
if (this.remaining_body > 0L && num > 0)
|
|
{
|
|
this.remaining_body -= (long)num;
|
|
}
|
|
return num;
|
|
}
|
|
|
|
// Token: 0x06001500 RID: 5376 RVA: 0x00043384 File Offset: 0x00041584
|
|
public override long Seek(long offset, SeekOrigin origin)
|
|
{
|
|
throw new NotSupportedException();
|
|
}
|
|
|
|
// Token: 0x06001501 RID: 5377 RVA: 0x0004338C File Offset: 0x0004158C
|
|
public override void SetLength(long value)
|
|
{
|
|
throw new NotSupportedException();
|
|
}
|
|
|
|
// Token: 0x06001502 RID: 5378 RVA: 0x00043394 File Offset: 0x00041594
|
|
public override void Write(byte[] buffer, int offset, int count)
|
|
{
|
|
throw new NotSupportedException();
|
|
}
|
|
|
|
// Token: 0x06001503 RID: 5379 RVA: 0x0004339C File Offset: 0x0004159C
|
|
public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback cback, object state)
|
|
{
|
|
throw new NotSupportedException();
|
|
}
|
|
|
|
// Token: 0x06001504 RID: 5380 RVA: 0x000433A4 File Offset: 0x000415A4
|
|
public override void EndWrite(IAsyncResult async_result)
|
|
{
|
|
throw new NotSupportedException();
|
|
}
|
|
|
|
// Token: 0x0400119F RID: 4511
|
|
private byte[] buffer;
|
|
|
|
// Token: 0x040011A0 RID: 4512
|
|
private int offset;
|
|
|
|
// Token: 0x040011A1 RID: 4513
|
|
private int length;
|
|
|
|
// Token: 0x040011A2 RID: 4514
|
|
private long remaining_body;
|
|
|
|
// Token: 0x040011A3 RID: 4515
|
|
private bool disposed;
|
|
|
|
// Token: 0x040011A4 RID: 4516
|
|
private Stream stream;
|
|
}
|
|
}
|