private void EndGetResponse(IAsyncResult ar, WebStreams state) { state.Response = (HttpWebResponse)state.Request.EndGetResponse(ar); state.StreamReader = state.Response.GetResponseStream(); if (state.StreamReader != null) { state.StreamReader.BeginRead(state.Buffer, 0, state.Buffer.Length, __EndReadResponse, state); } }
private void BeginGetResponse(WebStreams requestState) { requestState.Dispose(); var state = new WebStreams { StreamWriter = new MemoryStream(), Request = requestState.Request }; var ar = state.Request.BeginGetResponse(__EndGetResponse, state); ThreadPool.RegisterWaitForSingleObject(ar.AsyncWaitHandle, Je.web.TimeoutCallback, state.Request, Je.web.RequestTimeout, true); }
private void EndReadResponse(IAsyncResult ar, WebStreams state) { var read = state.StreamReader.EndRead(ar); if (read > 0) { state.StreamWriter.BeginWrite(state.Buffer, 0, read, __EndWriteMemory, state); } else { CommandThreads.Run(() => Completing(state)); } }
private void EndReadRequestMemory(IAsyncResult ar, WebStreams state) { var read = state.StreamReader.EndRead(ar); if (read > 0) { state.StreamWriter.BeginWrite(state.Buffer, 0, read, __EndWriteRequestStream, state); } else { BeginGetResponse(state); } }
private WebStreams BeginGetRequestStream() { var state = new WebStreams(); state.Request = CreateRequest(); state.StreamReader = Je.bin.ObjToMem(Value, Je.web.WebEncoding); if (state.StreamReader.Length == 0) { BeginGetResponse(state); return(state); } state.Request.ContentLength = state.StreamReader.Length; state.Request.BeginGetRequestStream(__EndGetRequestStream, state); return(state); }
private void Completing(WebStreams state) { try { var ms = state.StreamWriter as MemoryStream; if (ms != null) { Result = Je.bin.MemToObj <TResult>(ms, Je.web.WebEncoding); } state.Dispose(); EndExecuteEvent(Je.cmd.EmptyEventArgs(this)); } catch (Exception e) { state.Dispose(); Finalize(e); } }
private void EndWriteMemory(IAsyncResult ar, WebStreams state) { state.StreamWriter.EndWrite(ar); state.Reset(); state.StreamReader.BeginRead(state.Buffer, 0, state.Buffer.Length, __EndReadResponse, state); }
private void EndGetRequestStream(IAsyncResult ar, WebStreams state) { state.StreamWriter = state.Request.EndGetRequestStream(ar); state.StreamReader.BeginRead(state.Buffer, 0, state.Buffer.Length, __EndReadRequestMemory, state); }