internal unsafe HttpResponseStreamAsyncResult(object asyncObject, object userState, AsyncCallback callback, byte[] buffer, int offset, int size, bool chunked, bool sentHeaders) : base(asyncObject, userState, callback)
{
this.m_SentHeaders = sentHeaders;
Overlapped overlapped = new Overlapped {
AsyncResult = this
};
if (size == 0)
{
this.m_DataChunks = null;
this.m_pOverlapped = overlapped.Pack(s_IOCallback, null);
}
else
{
this.m_DataChunks = new UnsafeNclNativeMethods.HttpApi.HTTP_DATA_CHUNK[chunked ? 3 : 1];
object[] userData = new object[1 + this.m_DataChunks.Length];
userData[this.m_DataChunks.Length] = this.m_DataChunks;
int num = 0;
byte[] arr = null;
if (chunked)
{
arr = ConnectStream.GetChunkHeader(size, out num);
this.m_DataChunks[0] = new UnsafeNclNativeMethods.HttpApi.HTTP_DATA_CHUNK();
this.m_DataChunks[0].DataChunkType = UnsafeNclNativeMethods.HttpApi.HTTP_DATA_CHUNK_TYPE.HttpDataChunkFromMemory;
this.m_DataChunks[0].BufferLength = (uint) (arr.Length - num);
userData[0] = arr;
this.m_DataChunks[1] = new UnsafeNclNativeMethods.HttpApi.HTTP_DATA_CHUNK();
this.m_DataChunks[1].DataChunkType = UnsafeNclNativeMethods.HttpApi.HTTP_DATA_CHUNK_TYPE.HttpDataChunkFromMemory;
this.m_DataChunks[1].BufferLength = (uint) size;
userData[1] = buffer;
this.m_DataChunks[2] = new UnsafeNclNativeMethods.HttpApi.HTTP_DATA_CHUNK();
this.m_DataChunks[2].DataChunkType = UnsafeNclNativeMethods.HttpApi.HTTP_DATA_CHUNK_TYPE.HttpDataChunkFromMemory;
this.m_DataChunks[2].BufferLength = (uint) NclConstants.CRLF.Length;
userData[2] = NclConstants.CRLF;
}
else
{
this.m_DataChunks[0] = new UnsafeNclNativeMethods.HttpApi.HTTP_DATA_CHUNK();
this.m_DataChunks[0].DataChunkType = UnsafeNclNativeMethods.HttpApi.HTTP_DATA_CHUNK_TYPE.HttpDataChunkFromMemory;
this.m_DataChunks[0].BufferLength = (uint) size;
userData[0] = buffer;
}
this.m_pOverlapped = overlapped.Pack(s_IOCallback, userData);
if (chunked)
{
this.m_DataChunks[0].pBuffer = (byte*) Marshal.UnsafeAddrOfPinnedArrayElement(arr, num);
this.m_DataChunks[1].pBuffer = (byte*) Marshal.UnsafeAddrOfPinnedArrayElement(buffer, offset);
this.m_DataChunks[2].pBuffer = (byte*) Marshal.UnsafeAddrOfPinnedArrayElement(NclConstants.CRLF, 0);
}
else
{
this.m_DataChunks[0].pBuffer = (byte*) Marshal.UnsafeAddrOfPinnedArrayElement(buffer, offset);
}
}
}