本文整理汇总了C#中WebExceptionStatus类的典型用法代码示例。如果您正苦于以下问题:C# WebExceptionStatus类的具体用法?C# WebExceptionStatus怎么用?C# WebExceptionStatus使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WebExceptionStatus类属于命名空间,在下文中一共展示了WebExceptionStatus类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WebException
internal WebException(string message, string data, Exception innerException, WebExceptionStatus status, WebResponse response, WebExceptionInternalStatus internalStatus) : base(message + ((data != null) ? (": '" + data + "'") : ""), innerException)
{
this.m_Status = WebExceptionStatus.UnknownError;
this.m_Status = status;
this.m_Response = response;
this.m_InternalStatus = internalStatus;
}
示例2: ConnectionException
/// <summary>
/// Represents errors that occur during application execution
/// </summary>
/// <param name="message">The message that describes the error</param>
/// <param name="response">The response from server</param>
/// <param name="status">The <see cref="System.Net.WebExceptionStatus"/> that triggered this exception.</param>
/// <param name="request">HTTP request sent by this SDK.</param>
public ConnectionException(string message, string response, WebExceptionStatus status, HttpWebRequest request)
: base(message)
{
this.Response = response;
this.WebExceptionStatus = status;
this.Request = request;
}
示例3: InitOption
private void InitOption(HttpStatus status, HttpCause cause)
{
this.mStatus = status;
this.mCause = cause;
this.mHttpErrorResponse = null;
this.mWebStatus = WebExceptionStatus.Success;
}
示例4: BeginMultipleWrite
internal override IAsyncResult BeginMultipleWrite(BufferOffsetSize[] buffers, AsyncCallback callback, object state)
{
IAsyncResult result2;
if (!this.m_Worker.IsAuthenticated)
{
BufferAsyncResult result = new BufferAsyncResult(this, buffers, state, callback);
if (this.ProcessAuthentication(result))
{
return result;
}
}
try
{
result2 = this.m_Worker.SecureStream.BeginWrite(buffers, callback, state);
}
catch
{
if (this.m_Worker.IsCertValidationFailed)
{
this.m_ExceptionStatus = WebExceptionStatus.TrustFailure;
}
else if (this.m_Worker.LastSecurityStatus != SecurityStatus.OK)
{
this.m_ExceptionStatus = WebExceptionStatus.SecureChannelFailure;
}
else
{
this.m_ExceptionStatus = WebExceptionStatus.SendFailure;
}
throw;
}
return result2;
}
示例5: TlsStream
//
// This version of an Ssl Stream is for internal HttpWebrequest use.
// This Ssl client owns the underlined socket
// The TlsStream will own secured read/write and disposal of the passed "networkStream" stream.
//
public TlsStream(string destinationHost, NetworkStream networkStream, X509CertificateCollection clientCertificates, ServicePoint servicePoint, object initiatingRequest, ExecutionContext executionContext)
:base(networkStream, true) {
// WebRequest manages the execution context manually so we have to ensure we get one for SSL client certificate demand
_ExecutionContext = executionContext;
if (_ExecutionContext == null)
{
_ExecutionContext = ExecutionContext.Capture();
}
//
GlobalLog.Enter("TlsStream::TlsStream", "host="+destinationHost+", #certs="+((clientCertificates == null) ? "none" : clientCertificates.Count.ToString(NumberFormatInfo.InvariantInfo)));
if (Logging.On) Logging.PrintInfo(Logging.Web, this, ".ctor", "host="+destinationHost+", #certs="+((clientCertificates == null) ? "null" : clientCertificates.Count.ToString(NumberFormatInfo.InvariantInfo)));
m_ExceptionStatus = WebExceptionStatus.SecureChannelFailure;
m_Worker = new SslState(networkStream, initiatingRequest is HttpWebRequest, SettingsSectionInternal.Section.EncryptionPolicy);
m_DestinationHost = destinationHost;
m_ClientCertificates = clientCertificates;
RemoteCertValidationCallback certValidationCallback = servicePoint.SetupHandshakeDoneProcedure(this, initiatingRequest);
m_Worker.SetCertValidationDelegate(certValidationCallback);
// The Handshake is NOT done at this point
GlobalLog.Leave("TlsStream::TlsStream (Handshake is not done)");
}
示例6: WebException
public WebException(String msg, Exception inner,
WebExceptionStatus status, WebResponse response)
: base(msg, inner)
{
myresponse = response;
mystatus = status;
}
示例7: HttpWebException
static HttpWebException()
{
#if PORTABLE
if (!Enum.TryParse("ProtocolError", out ProtocolError))
ProtocolError = WebExceptionStatus.UnknownError;
#else
ProtocolError = WebExceptionStatus.ProtocolError;
#endif
}
示例8: WebException
public WebException(string message,
Exception innerException,
WebExceptionStatus status,
WebResponse response)
: base (message, innerException)
{
this.status = status;
this.response = response;
}
示例9: WebException
public WebException(string message,
Exception innerException,
WebExceptionStatus status,
WebResponse response) :
base(message, innerException)
{
_status = status;
_response = response;
if (innerException != null)
{
HResult = innerException.HResult;
}
}
示例10: GetWebStatusString
internal static string GetWebStatusString(WebExceptionStatus status)
{
int index = (int) status;
if ((index >= s_Mapping.Length) || (index < 0))
{
throw new InternalException();
}
string str = s_Mapping[index];
if (str == null)
{
str = "net_webstatus_" + status.ToString();
s_Mapping[index] = str;
}
return str;
}
示例11: GetWebStatusString
/*++
GetWebStatusString - Get a WebExceptionStatus-specific resource string
This method takes an input string and a WebExceptionStatus. We use the input
string as a key to find a status message and the webStatus to produce
a status-specific message, then we combine the two.
Input:
Res - Id for resource string.
Status - The WebExceptionStatus to be formatted.
Returns:
string for localized message.
--*/
public static string GetWebStatusString(string Res, WebExceptionStatus Status) {
string Msg;
string StatusMsg;
StatusMsg = SR.GetString(WebExceptionMapping.GetWebStatusString(Status));
// Get the base status.
Msg = SR.GetString(Res);
// Format the status specific message into the base status and return
// that
return String.Format(CultureInfo.CurrentCulture, Msg, StatusMsg);
}
示例12: FailRequest
protected internal virtual void FailRequest(WebExceptionStatus webStatus)
{
if (Logging.On)
{
Logging.PrintError(Logging.RequestCache, SR.GetString("net_log_cache_failing_request_with_exception", new object[] { webStatus.ToString() }));
}
if (webStatus == WebExceptionStatus.CacheEntryNotFound)
{
throw ExceptionHelper.CacheEntryNotFoundException;
}
if (webStatus == WebExceptionStatus.RequestProhibitedByCachePolicy)
{
throw ExceptionHelper.RequestProhibitedByCachePolicyException;
}
throw new WebException(NetRes.GetWebStatusString("net_requestaborted", webStatus), webStatus);
}
示例13: TlsStream
public TlsStream(string destinationHost, NetworkStream networkStream, X509CertificateCollection clientCertificates, ServicePoint servicePoint, object initiatingRequest, ExecutionContext executionContext) : base(networkStream, true)
{
this.m_PendingIO = new ArrayList();
this._ExecutionContext = executionContext;
if (this._ExecutionContext == null)
{
this._ExecutionContext = ExecutionContext.Capture();
}
if (Logging.On)
{
Logging.PrintInfo(Logging.Web, this, ".ctor", "host=" + destinationHost + ", #certs=" + ((clientCertificates == null) ? "null" : clientCertificates.Count.ToString(NumberFormatInfo.InvariantInfo)));
}
this.m_ExceptionStatus = WebExceptionStatus.SecureChannelFailure;
this.m_Worker = new SslState(networkStream, initiatingRequest is HttpWebRequest, SettingsSectionInternal.Section.EncryptionPolicy);
this.m_DestinationHost = destinationHost;
this.m_ClientCertificates = clientCertificates;
RemoteCertValidationCallback certValidationCallback = servicePoint.SetupHandshakeDoneProcedure(this, initiatingRequest);
this.m_Worker.SetCertValidationDelegate(certValidationCallback);
}
示例14: Send
public static string Send(string request)
{
try
{
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(request);
req.ReadWriteTimeout = 9000;
req.Timeout = 10000;
HttpWebResponse response = (HttpWebResponse)req.GetResponse();
status = KannelReqCode.SuccessfullyAccepted;
// Get the stream associated with the response.
Stream receiveStream = response.GetResponseStream();
// Pipes the stream to a higher level stream reader with the required encoding format.
StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8);
string answer = readStream.ReadLine();
//MessageBox.Show(response.StatusCode.ToString() + "\n" + readStream.ReadLine(), "SMS Sender", MessageBoxButtons.OK, MessageBoxIcon.Information);
response.Close();
readStream.Close();
return answer;
}
catch (WebException ex)
{
if (ex.Status == WebExceptionStatus.Timeout)
status = KannelReqCode.OperationTimeout;
else
status = KannelReqCode.UnknownError;
wes = ex.Status;
return ex.Message;
}
catch(Exception ex)
{
wes = WebExceptionStatus.SendFailure;
status = KannelReqCode.UnknownError;
return ex.Message;
}
}
示例15: ToRollbarStatus
private static RollbarResponseCode ToRollbarStatus(WebExceptionStatus status) {
switch ((int) status) {
case 200:
return RollbarResponseCode.Success;
case 400:
return RollbarResponseCode.BadRequest;
case 401:
return RollbarResponseCode.Unauthorized;
case 403:
return RollbarResponseCode.AccessDenied;
case 413:
return RollbarResponseCode.RequestTooLarge;
case 422:
return RollbarResponseCode.UnprocessablePayload;
case 429:
return RollbarResponseCode.TooManyRequests;
case 500:
return RollbarResponseCode.InternalServerError;
default:
throw new ArgumentException("Invalid Status returned from Rollbar", "status");
}
}