private void FinishRequest(EasyRequest completedOperation, int messageResult) { if (completedOperation.ResponseMessage.StatusCode != HttpStatusCode.Unauthorized && completedOperation.Handler.PreAuthenticate) { ulong availedAuth; if (Interop.libcurl.curl_easy_getinfo(completedOperation.EasyHandle, CURLINFO.CURLINFO_HTTPAUTH_AVAIL, out availedAuth) == CURLcode.CURLE_OK) { // TODO: fix locking in AddCredentialToCache completedOperation.Handler.AddCredentialToCache( completedOperation.RequestMessage.RequestUri, availedAuth, completedOperation.NetworkCredential); } // Ignore errors: no need to fail for the sake of putting the credentials into the cache } switch (messageResult) { case CURLcode.CURLE_OK: completedOperation.EnsureResponseMessagePublished(); break; default: completedOperation.FailRequest(CreateHttpRequestException(new CurlException(messageResult, isMulti: false))); break; } // At this point, we've completed processing the entire request, either due to error // or due to completing the entire response. completedOperation.Cleanup(); }
private void FinishRequest(EasyRequest completedOperation, CURLcode messageResult) { VerboseTrace("messageResult: " + messageResult, easy: completedOperation); if (completedOperation._responseMessage.StatusCode != HttpStatusCode.Unauthorized) { if (completedOperation._handler.PreAuthenticate) { long authAvailable; if (Interop.Http.EasyGetInfoLong(completedOperation._easyHandle, CURLINFO.CURLINFO_HTTPAUTH_AVAIL, out authAvailable) == CURLcode.CURLE_OK) { completedOperation._handler.AddCredentialToCache( completedOperation._requestMessage.RequestUri, (CURLAUTH)authAvailable, completedOperation._networkCredential); } // Ignore errors: no need to fail for the sake of putting the credentials into the cache } completedOperation._handler.AddResponseCookies( completedOperation._requestMessage.RequestUri, completedOperation._responseMessage); } // Complete or fail the request try { bool unsupportedProtocolRedirect = messageResult == CURLcode.CURLE_UNSUPPORTED_PROTOCOL && completedOperation._isRedirect; if (!unsupportedProtocolRedirect) { ThrowIfCURLEError(messageResult); } completedOperation.EnsureResponseMessagePublished(); } catch (Exception exc) { completedOperation.FailRequest(exc); } // At this point, we've completed processing the entire request, either due to error // or due to completing the entire response. completedOperation.Cleanup(); }
private void FinishRequest(EasyRequest completedOperation, int messageResult) { VerboseTrace("messageResult: " + messageResult, easy: completedOperation); if (completedOperation._responseMessage.StatusCode != HttpStatusCode.Unauthorized && completedOperation._handler.PreAuthenticate) { ulong availedAuth; if (Interop.libcurl.curl_easy_getinfo(completedOperation._easyHandle, CURLINFO.CURLINFO_HTTPAUTH_AVAIL, out availedAuth) == CURLcode.CURLE_OK) { // TODO: fix locking in AddCredentialToCache completedOperation._handler.AddCredentialToCache( completedOperation._requestMessage.RequestUri, availedAuth, completedOperation._networkCredential); } // Ignore errors: no need to fail for the sake of putting the credentials into the cache } switch (messageResult) { case CURLcode.CURLE_OK: completedOperation.EnsureResponseMessagePublished(); break; default: completedOperation.FailRequest(CreateHttpRequestException(new CurlException(messageResult, isMulti: false))); break; } // At this point, we've completed processing the entire request, either due to error // or due to completing the entire response. completedOperation.Cleanup(); }