Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ BeginReadCore()

unsafe IAsyncResult System.Net.HttpRequestStream.BeginReadCore ( byte[] buffer,
int offset,
int size,
AsyncCallback callback,
object state )
inline

Definition at line 295 of file HttpRequestStream.cs.

296 {
297 if (size == 0 || _closed)
298 {
299 HttpRequestStreamAsyncResult httpRequestStreamAsyncResult = new HttpRequestStreamAsyncResult(this, state, callback);
300 httpRequestStreamAsyncResult.InvokeCallback(0u);
301 return httpRequestStreamAsyncResult;
302 }
303 HttpRequestStreamAsyncResult httpRequestStreamAsyncResult2 = null;
304 uint num = 0u;
305 if (_dataChunkIndex != -1)
306 {
308 if (_dataChunkIndex != -1 && num == size)
309 {
310 httpRequestStreamAsyncResult2 = new HttpRequestStreamAsyncResult(_httpContext.RequestQueueBoundHandle, this, state, callback, buffer, offset, (uint)size, 0u);
311 httpRequestStreamAsyncResult2.InvokeCallback(num);
312 }
313 }
314 if (_dataChunkIndex == -1 && num < size)
315 {
316 if (System.Net.NetEventSource.Log.IsEnabled())
317 {
318 System.Net.NetEventSource.Info(this, "size:" + size + " offset:" + offset, "BeginReadCore");
319 }
320 uint num2 = 0u;
321 offset += (int)num;
322 size -= (int)num;
323 if (size > 131072)
324 {
325 size = 131072;
326 }
327 httpRequestStreamAsyncResult2 = new HttpRequestStreamAsyncResult(_httpContext.RequestQueueBoundHandle, this, state, callback, buffer, offset, (uint)size, num);
328 uint bytesReturned;
329 try
330 {
331 fixed (byte* ptr = buffer)
332 {
333 if (System.Net.NetEventSource.Log.IsEnabled())
334 {
335 System.Net.NetEventSource.Info(this, "Calling Interop.HttpApi.HttpReceiveRequestEntityBody", "BeginReadCore");
336 }
337 uint flags = 0u;
338 if (!_inOpaqueMode)
339 {
340 flags = 1u;
341 }
342 num2 = global::Interop.HttpApi.HttpReceiveRequestEntityBody(_httpContext.RequestQueueHandle, _httpContext.RequestId, flags, httpRequestStreamAsyncResult2._pPinnedBuffer, (uint)size, out bytesReturned, httpRequestStreamAsyncResult2._pOverlapped);
343 if (System.Net.NetEventSource.Log.IsEnabled())
344 {
345 System.Net.NetEventSource.Info(this, "Call to Interop.HttpApi.HttpReceiveRequestEntityBody returned:" + num2 + " dataRead:" + num, "BeginReadCore");
346 }
347 }
348 }
349 catch (Exception ex)
350 {
351 if (System.Net.NetEventSource.Log.IsEnabled())
352 {
353 System.Net.NetEventSource.Error(this, ex.ToString(), "BeginReadCore");
354 }
355 httpRequestStreamAsyncResult2.InternalCleanup();
356 throw;
357 }
358 if (num2 != 0 && num2 != 997)
359 {
360 httpRequestStreamAsyncResult2.InternalCleanup();
361 if (num2 != 38)
362 {
363 Exception ex2 = new HttpListenerException((int)num2);
364 if (System.Net.NetEventSource.Log.IsEnabled())
365 {
366 System.Net.NetEventSource.Error(this, ex2.ToString(), "BeginReadCore");
367 }
368 httpRequestStreamAsyncResult2.InternalCleanup();
369 throw ex2;
370 }
371 httpRequestStreamAsyncResult2 = new HttpRequestStreamAsyncResult(this, state, callback, num);
372 httpRequestStreamAsyncResult2.InvokeCallback(0u);
373 }
374 else if (num2 == 0 && HttpListener.SkipIOCPCallbackOnSuccess)
375 {
376 httpRequestStreamAsyncResult2.IOCompleted(num2, bytesReturned);
377 }
378 }
379 return httpRequestStreamAsyncResult2;
380 }
ThreadPoolBoundHandle RequestQueueBoundHandle
readonly HttpListenerContext _httpContext
static readonly System.Net.NetEventSource Log
static void Info(object thisOrContextObject, FormattableString formattableString=null, [CallerMemberName] string memberName=null)
static void Error(object thisOrContextObject, FormattableString formattableString, [CallerMemberName] string memberName=null)

References System.Net.HttpRequestStream._closed, System.Net.HttpRequestStream._dataChunkIndex, System.Net.HttpRequestStream._dataChunkOffset, System.Net.HttpRequestStream._httpContext, System.Net.HttpRequestStream._inOpaqueMode, System.Net.HttpRequestStream.HttpRequestStreamAsyncResult._pOverlapped, System.Net.HttpRequestStream.HttpRequestStreamAsyncResult._pPinnedBuffer, System.buffer, System.Net.NetEventSource.Error(), System.Net.NetEventSource.Info(), System.Net.LazyAsyncResult.InternalCleanup(), System.Net.LazyAsyncResult.InvokeCallback(), System.Net.HttpRequestStream.HttpRequestStreamAsyncResult.IOCompleted(), System.Net.NetEventSource.Log, System.offset, System.Net.HttpListenerRequest.OriginalBlobAddress, System.Net.HttpListenerContext.Request, System.Net.HttpListenerRequest.RequestBuffer, System.Net.HttpListenerContext.RequestId, System.Net.HttpListenerContext.RequestQueueBoundHandle, System.Net.HttpListenerContext.RequestQueueHandle, System.Net.HttpListener.SkipIOCPCallbackOnSuccess, System.state, and System.Exception.ToString().

Referenced by System.Net.HttpRequestStream.BeginRead().