public void Write(IRemoraOperation operation, IUniversalResponse response) { if (operation == null) throw new ArgumentNullException("operation"); if (response == null) throw new ArgumentNullException("response"); Contract.EndContractBlock(); if (operation.OnError) { Logger.ErrorFormat(operation.Exception, "There has been an error when processing request coming from {0}.", operation.IncomingUri); _exceptionformatter.WriteException(operation, response); } else { response.StatusCode = operation.Response.StatusCode; foreach (var header in operation.Response.HttpHeaders) { response.SetHeader(header.Key, header.Value); } if (operation.Response.Data != null) { response.OutputStream.Write(operation.Response.Data, 0, operation.Response.Data.Length); } response.OutputStream.Flush(); } }
protected virtual void WriteSoap(IRemoraOperation operation, IUniversalResponse response) { response.ContentType = "text/xml"; response.StatusCode = (int) HttpStatusCode.OK; response.ContentEncoding = Encoding.UTF8; var content = response.ContentEncoding.GetBytes(string.Format(ErrorResources.SoapError, operation.Exception.GetType().Name.Replace( "Exception", ""), operation.Exception.Message)); response.OutputStream.Write(content, 0, content.Length); response.OutputStream.Flush(); }
public void WriteException(IRemoraOperation operation, IUniversalResponse response) { if (operation == null) throw new ArgumentNullException("operation"); if (response == null) throw new ArgumentNullException("response"); Contract.EndContractBlock(); switch (operation.Kind) { case RemoraOperationKind.Soap: WriteSoap(operation, response); break; default: WriteHtmlException(operation.Exception, response); break; } }
public void WriteHtmlException(Exception exception, IUniversalResponse response) { if (exception == null) throw new ArgumentNullException("exception"); if (response == null) throw new ArgumentNullException("response"); Contract.EndContractBlock(); response.StatusCode = (int) HttpStatusCode.InternalServerError; response.ContentType = "text/html"; response.ContentEncoding = Encoding.UTF8; var content = response.ContentEncoding.GetBytes(string.Format(ErrorResources.GenericHtmlError, exception.GetType().Name.Replace("Exception", ""), exception.Message)); response.OutputStream.Write(content, 0, content.Length); response.OutputStream.Flush(); }
public SomeController() { gProcessRequest = new ProcessRequest(new UserRepository(Request.Properties)); }