/// <summary> /// /// </summary> /// <param name="command"></param> /// <returns></returns> public HttpWebResponse GetHttpWebResponse(HttpRequestCommand command) { HttpWebRequest req = this.CreateRequest(command); StreamWriteContext scx = null; if (command.BodyStream != null && command.IsSendBodyStream == true) { //Request body //req.ContentLength = command.BodyStream.Length; if (command.BodyStream.Length > 0) { using (var stm = req.GetRequestStream()) { if (this.RequestBufferSize.HasValue == true) { scx = new StreamWriteContext(stm, this.RequestBufferSize.Value); } else { scx = new StreamWriteContext(stm); } scx.Uploading += (o, e) => this.OnUploading(e); scx.Write(command.BodyStream); stm.Dispose(); } } } return(req.GetResponse() as HttpWebResponse); }
private void WriteRequestStream(IAsyncResult result) { var cx = this; Stream stm = null; StreamWriteContext scx = null; try { var req = result.AsyncState as HttpWebRequest; stm = req.EndGetRequestStream(result); scx = new StreamWriteContext(stm, this.RequestBufferSize); scx.Uploading += (o, e) => this.OnUploading(e); scx.Write(_Command.BodyStream); stm.Dispose(); stm = null; req.BeginGetResponse(this.GetResponse, req); } catch (Exception ex) { this.OnError(ex); } finally { if (stm != null) { stm.Dispose(); } } }
/// <summary> /// /// </summary> /// <param name="command"></param> /// <returns></returns> public HttpWebResponse GetHttpWebResponse(HttpRequestCommand command) { HttpWebRequest req = this.CreateRequest(command); StreamWriteContext scx = null; if (command.BodyStream != null && command.IsSendBodyStream == true) { //Request body //req.ContentLength = command.BodyStream.Length; if (command.BodyStream.Length > 0) { using (var stm = req.GetRequestStream()) { if (this.RequestBufferSize.HasValue == true) { scx = new StreamWriteContext(stm, this.RequestBufferSize.Value); } else { scx = new StreamWriteContext(stm); } scx.Uploading += (o, e) => this.OnUploading(e); scx.Write(command.BodyStream); stm.Dispose(); } } } return req.GetResponse() as HttpWebResponse; }
private void WriteRequestStream(IAsyncResult result) { var cx = this; Stream stm = null; StreamWriteContext scx = null; try { var req = result.AsyncState as HttpWebRequest; stm = req.EndGetRequestStream(result); if (this.RequestBufferSize.HasValue == true) { scx = new StreamWriteContext(stm, this.RequestBufferSize.Value); } else { scx = new StreamWriteContext(stm); } scx.Uploading += (o, e) => this.OnUploading(e); scx.Write(_Command.BodyStream); stm.Dispose(); stm = null; req.BeginGetResponse(this.GetResponse, req); } catch (Exception ex) { this.OnError(ex); } finally { if (stm != null) { stm.Dispose(); } } }