private Task WriteToInjectScriptSocketAsync(bool firstWrite, byte[] buffer, int offset, int count, CancellationToken cancellationToken)
 {
     if (firstWrite)
     {
         return(FirstWriteToInjectScriptSocketAsync(buffer, offset, count, cancellationToken));
     }
     else
     {
         return(_injectScriptSocket.WriteToRequestAsync(buffer, offset, count));
     }
 }
Beispiel #2
0
        /// <remarks>
        /// This function is the pump that pushes data from the buffers into an
        /// HTTP connection. It asynchronously waits on data, then asynchronously
        /// waits while the data is sent, then waits on more data, etc.
        /// </remarks>
        private static async void SendDataFromBuffersAsync(RevolvingBuffers <byte> buffer, IHttpSocketAdapter adapter)
        {
            while (true)
            {
                ArraySegment <byte> bufferToSend = await buffer.GetBufferedDataAsync();

                if (bufferToSend.Count == 0)
                {
                    break;
                }

                await adapter.WriteToRequestAsync(bufferToSend.Array, bufferToSend.Offset, bufferToSend.Count);
            }

            await adapter.CompleteRequest();

            adapter.Dispose();
        }
Beispiel #3
0
        async Task IHttpSocketAdapter.WriteToRequestAsync(byte[] buffer, int offset, int count)
        {
            IHttpSocketAdapter socket = await GetConnectedSocketAsync();

            await socket.WriteToRequestAsync(buffer, offset, count);
        }