public override void Authenticate() { Logger.Debug("Authenticating connection {0}", LogSource.Channel, UniqueId); if (channelState == ChannelState.Authenticated) { return; } if (channelState != ChannelState.Connected) { Logger.Error("Unable to authenticate in current channel state. ChannelState = {0}", LogSource.Channel, channelState); throw new ChannelException("Unable to authenticate in current channel state"); } try { client.Capability(); client.YahooImap(); client.Authenticate(Username, Password); channelState = ChannelState.Authenticated; Logger.Debug("SUCCESS Authenticating connection {0}", LogSource.Channel, UniqueId); } catch (IMAP_ClientException ex) { channelState = ChannelState.Broken; Logger.Debug("FAILED Authenticating connection {0}. Server said {1}", LogSource.Channel, UniqueId, ex.ResponseText); throw new ChannelAuthenticationException(ex.ResponseText, ex); } }
public MemoryStream GetContentStream() { HttpWebResponse response = null; try { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); if (prepareRequest != null) { prepareRequest(request); } response = (HttpWebResponse)request.GetResponse(); MemoryStream ms = new MemoryStream(); var stream = response.GetResponseStream(); stream.CopyTo(ms); stream.Dispose(); return(ms); } catch (Exception ex) { if (response != null && response.StatusCode != HttpStatusCode.NotFound) { // Don't log 404 Logger.Error("An error has occured while trying to retrieve the web resource, Exception = {0}", LogSource.Channel, ex); } return(null); } }