/// <summary> /// Return a failure message. /// </summary> /// <param name="method">origin of the failure message</param> /// <param name="message">failure message</param> /// <remarks>This should probably set a return code as /// well. (?)</remarks> protected string Failure(OSHttpResponse response, OSHttpStatusCode status, string method, string format, params string[] msg) { string m = String.Format(format, msg); response.StatusCode = (int)status; response.StatusDescription = m; m_log.ErrorFormat("{0} {1} failed: {2}", MsgID, method, m); return(String.Format("<error>{0}</error>", m)); }
/// <summary> /// Return a failure message. /// </summary> /// <param name="method">origin of the failure message</param> /// <param name="e">exception causing the failure message</param> /// <remarks>This should probably set a return code as /// well. (?)</remarks> public string Failure(OSHttpResponse response, OSHttpStatusCode status, string method, Exception e) { string m = String.Format("exception occurred: {0}", e.Message); response.StatusCode = (int)status; response.StatusDescription = m; m_log.DebugFormat("{0} {1} failed: {2}", MsgID, method, e.ToString()); m_log.ErrorFormat("{0} {1} failed: {2}", MsgID, method, e.Message); return(String.Format("<error>{0}</error>", e.Message)); }
/// <summary> /// The server has decided not to allow the upgrade to a websocket for some reason. The Http 1.1 response that says Nay >:( /// </summary> /// <param name="pCode">HTTP Status reflecting the reason why</param> /// <param name="pMessage">Textual reason for the upgrade fail</param> private void FailUpgrade(OSHttpStatusCode pCode, string pMessage) { string handshakeResponse = string.Format(HandshakeDeclineText, (int)pCode, pMessage.Replace("\n", string.Empty).Replace("\r", string.Empty)); byte[] bhandshakeResponse = Encoding.UTF8.GetBytes(handshakeResponse); _networkContext.Stream.Write(bhandshakeResponse, 0, bhandshakeResponse.Length); _networkContext.Stream.Flush(); _networkContext.Stream.Dispose(); UpgradeFailedDelegate d = OnUpgradeFailed; if (d != null) { d(this, new UpgradeFailedEventArgs()); } }
/// <summary> /// The server has decided not to allow the upgrade to a websocket for some reason. The Http 1.1 response that says Nay >:( /// </summary> /// <param name="pCode">HTTP Status reflecting the reason why</param> /// <param name="pMessage">Textual reason for the upgrade fail</param> private void FailUpgrade(OSHttpStatusCode pCode, string pMessage ) { string handshakeResponse = string.Format(HandshakeDeclineText, (int)pCode, pMessage.Replace("\n", string.Empty).Replace("\r", string.Empty)); byte[] bhandshakeResponse = Encoding.UTF8.GetBytes(handshakeResponse); _networkContext.Stream.Write(bhandshakeResponse, 0, bhandshakeResponse.Length); _networkContext.Stream.Flush(); _networkContext.Stream.Dispose(); UpgradeFailedDelegate d = OnUpgradeFailed; if (d != null) d(this,new UpgradeFailedEventArgs()); }
/// <summary> /// Return a failure message. /// </summary> /// <param name="method">origin of the failure message</param> /// <param name="e">exception causing the failure message</param> /// <remarks>This should probably set a return code as /// well. (?)</remarks> public string Failure(OSHttpResponse response, OSHttpStatusCode status, string method, Exception e) { string m = String.Format("exception occurred: {0}", e.Message); response.StatusCode = (int) status; response.StatusDescription = m; m_log.DebugFormat("{0} {1} failed: {2}", MsgID, method, e.ToString()); m_log.ErrorFormat("{0} {1} failed: {2}", MsgID, method, e.Message); return String.Format("<error>{0}</error>", e.Message); }
/// <summary> /// Return a failure message. /// </summary> /// <param name="method">origin of the failure message</param> /// <param name="message">failure message</param> /// <remarks>This should probably set a return code as /// well. (?)</remarks> protected string Failure(OSHttpResponse response, OSHttpStatusCode status, string method, string format, params string[] msg) { string m = String.Format(format, msg); response.StatusCode = (int) status; response.StatusDescription = m; m_log.ErrorFormat("{0} {1} failed: {2}", MsgID, method, m); return String.Format("<error>{0}</error>", m); }