JornWildt / Ramone

A C# client framework for consuming HTTP/REST services
Other
61 stars 11 forks source link

Error handler not invoked #40

Closed JornWildt closed 6 years ago

JornWildt commented 7 years ago

Consider this example:

private async Task<Response> GetResponse(Request request, T data)
{
  TaskCompletionSource<Response> tcs = new TaskCompletionSource<Response>();
  request.Async()
    .OnError(err => tcs.TrySetException(err.Exception))
    .Post(data, response => tcs.SetResult(response));
  return await tcs.Task;
}

If the request points to a non-existing server or port with no HTTP service, the code fails without invoking OnError().

The problem lies in HandleGetRequestStream of AsyncEventRequest where there is no error checking of the async result - it will call EndGetRequestStream even if no stream is available.