Esempio n. 1
0
 /// <summary>Output 404 with appropriate message.</summary>
 /// <param name="resp">the http response.</param>
 /// <param name="message">the message to include on the page.</param>
 /// <exception cref="System.IO.IOException">on any error.</exception>
 public static void NotFound(HttpServletResponse resp, string message)
 {
     resp.SetStatus(HttpServletResponse.ScNotFound);
     resp.SetContentType(MimeType.Html);
     ProxyUtils.Page p = new ProxyUtils.Page(resp.GetWriter());
     p.Html().H1(message).();
 }
Esempio n. 2
0
        /// <summary>
        /// Handle redirects with a status code that can in future support verbs other
        /// than GET, thus supporting full REST functionality.
        /// </summary>
        /// <remarks>
        /// Handle redirects with a status code that can in future support verbs other
        /// than GET, thus supporting full REST functionality.
        /// <p>
        /// The target URL is included in the redirect text returned
        /// <p>
        /// At the end of this method, the output stream is closed.
        /// </remarks>
        /// <param name="request">
        /// request (hence: the verb and any other information
        /// relevant to a redirect)
        /// </param>
        /// <param name="response">the response</param>
        /// <param name="target">the target URL -unencoded</param>
        /// <exception cref="System.IO.IOException"/>
        public static void SendRedirect(HttpServletRequest request, HttpServletResponse response
                                        , string target)
        {
            if (Log.IsDebugEnabled())
            {
                Log.Debug("Redirecting {} {} to {}", request.GetMethod(), request.GetRequestURI()
                          , target);
            }
            string location = response.EncodeRedirectURL(target);

            response.SetStatus(HttpServletResponse.ScFound);
            response.SetHeader(Location, location);
            response.SetContentType(MimeType.Html);
            PrintWriter writer = response.GetWriter();

            ProxyUtils.Page p = new ProxyUtils.Page(writer);
            p.Html().Head().Title("Moved").().Body().H1("Moved").Div().("Content has moved ")
            .A(location, "here").().().();
            writer.Close();
        }