square/okhttp — pull request #1126 by LaLiLuLeLo (2014-11-04 22:18:21+00:00)
Title: Callback logic modification

I've changed how Callback interface is called.

My problem with current version (2.0):
- If onResponse() is called and during his execution I try to cancel the Call - Call.cancel() has no effect - I can only cancel request which didn't yet been executed
- onFailure() can only be called if onReponse() hasn't be called

From my point of view, onFailure() and onReponse() doesn't follow usual way how you would respond to processing of network request. When using Callback I would like that every failure/Exception is wrapped up and onFailure() is called for that Exception.
Also, I would like that I can interrupt/cancel whole process of network request, not just before onResponse() is called.

I have generalized type of Exception in Callback interface and made that Call.call() actually interrupts thread and calls onFailure(). With Call.isCanceled() you can see that request has been canceled or Exception is some kind of error in processing.