开发者

Does calling Abort on HttpWebRequest has any affect on responseStream.BeginRead

From MSDN:

"The Ab开发者_开发技巧ort method cancels a request to a resource. After a request is canceled, calling the GetResponse, BeginGetResponse, EndGetResponse, GetRequestStream, BeginGetRequestStream, or EndGetRequestStream method causes a WebException with the Status property set to RequestCanceled."

But if responseStream.BeginRead is in progress, does Abort cancel this read?


Yes, it is affecting reading from a stream. I have tested sample code that was used in msdn HttpWebRequest.Abort Method, and call to EndRead was throwing an exception in ReadCallBack function.

RequestState myRequestState = (RequestState)asyncResult.AsyncState;
Stream responseStream = myRequestState.streamResponse;
int read = responseStream.EndRead(asyncResult);

ReadCallBack Exception raised!

Message:The request was aborted: The request was canceled.

Status:RequestCanceled Press any key to continue..........

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜