An object that writes a response to a safe HTTP request (e.g. GET, HEAD).
 /// <summary>
 /// Creates a request handler from the result of the specified data-modification method. If you do not need to modify data, do not call this constructor;
 /// use <see cref="EwfSafeResponseWriter"/>, which can be implicitly converted to a request handler.
 /// </summary>
 public EwfSafeRequestHandler(Func <EwfSafeResponseWriter> dataModificationMethod)
 {
     DataAccessState.Current.DisableCache();
     try {
         responseWriter = dataModificationMethod();
     }
     finally {
         DataAccessState.Current.ResetCache();
     }
 }
Example #2
0
        internal static void WriteRedirectResponse(HttpContext context, string url, bool permanent)
        {
            context.Response.StatusCode = permanent ? 308 : 307;

            if (context.Request.HttpMethod == "GET" || context.Request.HttpMethod == "HEAD")
            {
                EwfSafeResponseWriter.AddCacheControlHeader(
                    context.Response,
                    EwfApp.Instance.RequestIsSecure(context.Request),
                    false,
                    permanent ? (bool?)null : false);
            }

            EwfResponse.Create(
                ContentTypes.PlainText,
                new EwfResponseBodyCreator(writer => writer.Write("{0} Redirect: {1}".FormatWith(permanent ? "Permanent" : "Temporary", url))),
                additionalHeaderFieldGetter: () => ("Location", url).ToCollection())
            .WriteToAspNetResponse(context.Response, omitBody: context.Request.HttpMethod == "HEAD");
        }
 /// <summary>
 /// Development Utility use only.
 /// </summary>
 public static string GetUrlVersionString(DateTimeOffset dateAndTime)
 {
     return(urlVersionStringPrefix + EwfSafeResponseWriter.GetUrlVersionString(dateAndTime));
 }
Example #4
0
 /// <summary>
 /// Framework use only.
 /// </summary>
 protected string getUrlVersionString() => isVersioned?EwfSafeResponseWriter.GetUrlVersionString(GetResourceLastModificationDateAndTime()) : "";
 private EwfSafeRequestHandler(EwfSafeResponseWriter responseWriter)
 {
     this.responseWriter = responseWriter;
 }