}\r
\r
if (this.CookieContainer != null) \r
- {
- string cookieHeader = this.CookieContainer.GetCookieHeader (this.GetOriginalAddress());
- if (cookieHeader != "")
- _method.setRequestHeader("Cookie", cookieHeader);
+ {\r
+ string cookieHeader = this.CookieContainer.GetCookieHeader (this.GetOriginalAddress());\r
+ if (cookieHeader != "")\r
+ _method.setRequestHeader("Cookie", cookieHeader);\r
}\r
SetConnectionHeader(Headers["Connection"]);\r
\r
{\r
if(_asyncWrite != null)\r
{\r
- throw new InvalidOperationException ("Cannot re-call start of asynchronous " +
- "method while a previous call is still in progress.");
- }
-
- _asyncWrite = new GHWebAsyncResult (this, callback, state);
- if (_hasRequest)
- {
- if (_writeStream != null)
- {
- _asyncWrite.SetCompleted (true, _writeStream);
- _asyncWrite.DoCallback ();
- return _asyncWrite;
+ throw new InvalidOperationException ("Cannot re-call start of asynchronous " +\r
+ "method while a previous call is still in progress.");\r
+ }\r
+ \r
+ _asyncWrite = new GHWebAsyncResult (this, callback, state);\r
+ if (_hasRequest) \r
+ {\r
+ if (_writeStream != null) \r
+ {\r
+ _asyncWrite.SetCompleted (true, _writeStream);\r
+ _asyncWrite.DoCallback ();\r
+ return _asyncWrite;\r
}\r
}\r
\r
_asyncWrite.SetCompleted(false, e);\r
}\r
\r
- _asyncWrite.SetCompleted (true, _writeStream);
- _asyncWrite.DoCallback ();
+ _asyncWrite.SetCompleted (true, _writeStream);\r
+ _asyncWrite.DoCallback ();\r
return _asyncWrite;\r
\r
}\r
\r
public override Stream EndGetRequestStream(IAsyncResult asyncResult)\r
{\r
- if (asyncResult == null)
- throw new ArgumentNullException ("asyncResult");
-
- GHWebAsyncResult result = asyncResult as GHWebAsyncResult;
- if (result == null)
- throw new ArgumentException ("Invalid IAsyncResult");
-
- _asyncWrite = result;
-
- result.WaitUntilComplete ();
-
- Exception e = result.Exception;
-
- if (e != null)
- throw e;
-
+ if (asyncResult == null)\r
+ throw new ArgumentNullException ("asyncResult");\r
+\r
+ GHWebAsyncResult result = asyncResult as GHWebAsyncResult;\r
+ if (result == null)\r
+ throw new ArgumentException ("Invalid IAsyncResult");\r
+\r
+ _asyncWrite = result;\r
+\r
+ result.WaitUntilComplete ();\r
+\r
+ Exception e = result.Exception;\r
+ \r
+ if (e != null)\r
+ throw e;\r
+\r
return result.WriteStream;\r
}\r
\r
{\r
if(_asyncRead != null && !_hasResponse)\r
{\r
- throw new InvalidOperationException ("Cannot re-call start of asynchronous " +
- "method while a previous call is still in progress.");
- }
-
- _asyncRead = new GHWebAsyncResult (this, callback, state);
- if (_hasResponse)
- {
- if (_response != null)
- {
- _asyncRead.SetCompleted (true, _writeStream);
- _asyncRead.DoCallback ();
- return _asyncRead;
+ throw new InvalidOperationException ("Cannot re-call start of asynchronous " +\r
+ "method while a previous call is still in progress.");\r
+ }\r
+ \r
+ _asyncRead = new GHWebAsyncResult (this, callback, state);\r
+ if (_hasResponse) \r
+ {\r
+ if (_response != null) \r
+ {\r
+ _asyncRead.SetCompleted (true, _writeStream);\r
+ _asyncRead.DoCallback ();\r
+ return _asyncRead;\r
}\r
}\r
\r
catch(Exception e)\r
{\r
_asyncRead.SetCompleted(false, e);\r
- }
- _asyncRead.SetCompleted (true, _writeStream);
- _asyncRead.DoCallback ();
+ }\r
+ _asyncRead.SetCompleted (true, _writeStream);\r
+ _asyncRead.DoCallback (); \r
return _asyncRead;\r
\r
}\r
\r
public override WebResponse EndGetResponse(IAsyncResult asyncResult)\r
{\r
- if (asyncResult == null)
- throw new ArgumentNullException ("asyncResult");
-
- GHWebAsyncResult result = asyncResult as GHWebAsyncResult;
- if (result == null)
- throw new ArgumentException ("Invalid IAsyncResult", "asyncResult");
-
-
- _asyncRead = result;
+ if (asyncResult == null)\r
+ throw new ArgumentNullException ("asyncResult");\r
+\r
+ GHWebAsyncResult result = asyncResult as GHWebAsyncResult;\r
+ if (result == null)\r
+ throw new ArgumentException ("Invalid IAsyncResult", "asyncResult");\r
+\r
+ \r
+ _asyncRead = result;\r
if (!result.WaitUntilComplete (_timeout, false)) \r
- {
- Abort ();
- throw new WebException("The request timed out", WebExceptionStatus.Timeout);
- }
-
+ {\r
+ Abort ();\r
+ throw new WebException("The request timed out", WebExceptionStatus.Timeout);\r
+ }\r
+ \r
return result.Response;\r
}\r
\r
}\r
\r
public WaitHandle AsyncWaitHandle \r
- {
+ {\r
get \r
- {
+ {\r
if (_handle == null) \r
- {
+ {\r
lock (this) \r
- {
- if (_handle == null)
- _handle = new ManualResetEvent (_isCompleted);
- }
- }
-
- return _handle;
- }
+ {\r
+ if (_handle == null)\r
+ _handle = new ManualResetEvent (_isCompleted);\r
+ }\r
+ }\r
+ \r
+ return _handle;\r
+ }\r
}\r
\r
public bool IsCompleted\r
internal void DoCallback()\r
{\r
if (!_callbackDone && _callback != null) \r
- {
- _callbackDone = true;
- _callback (this);
+ {\r
+ _callbackDone = true;\r
+ _callback (this);\r
}\r
}\r
\r
AsyncWaitHandle.WaitOne ();\r
}\r
\r
- internal bool WaitUntilComplete (int timeout, bool exitContext)
- {
- if (_isCompleted)
- return true;
-
- return AsyncWaitHandle.WaitOne (timeout, exitContext);
+ internal bool WaitUntilComplete (int timeout, bool exitContext)\r
+ {\r
+ if (_isCompleted)\r
+ return true;\r
+\r
+ return AsyncWaitHandle.WaitOne (timeout, exitContext);\r
}\r
#endregion\r
\r