コード例 #1
0
        /// <summary><inheritDoc/></summary>
        /// <exception cref="Javax.Servlet.ServletException"/>
        /// <exception cref="System.IO.IOException"/>
        protected override void DoGet(IHttpServletRequest request, IHttpServletResponse response)
        {
            logger.Info("GET SPIED query from " + request.GetRemoteAddr());
            if (request.GetCharacterEncoding() == null)
            {
                request.SetCharacterEncoding("utf-8");
            }
            response.SetContentType("text/json; charset=UTF-8");
            PrintWriter @out = response.GetWriter();

            try
            {
                string raw       = request.GetParameter("q");
                string seedwords = request.GetParameter("seedwords");
                string model     = request.GetParameter("model");
                if (raw == null || string.Empty.Equals(raw))
                {
                    @out.Print("{\"okay\":false,\"reason\":\"No data provided\"}");
                }
                else
                {
                    Run(@out, raw, seedwords, model);
                }
            }
            catch (Exception t)
            {
                WriteError(t, @out, request.ToString());
            }
            @out.Close();
        }
コード例 #2
0
 /// <exception cref="Javax.Servlet.ServletException"/>
 /// <exception cref="System.IO.IOException"/>
 protected override void DoGet(IHttpServletRequest request, IHttpServletResponse response)
 {
     if (request.GetCharacterEncoding() == null)
     {
         request.SetCharacterEncoding("utf-8");
     }
     response.SetContentType("text/html; charset=UTF-8");
     this.GetServletContext().GetRequestDispatcher("/header.jsp").Include(request, response);
     AddResults(request, response);
     this.GetServletContext().GetRequestDispatcher("/footer.jsp").Include(request, response);
 }
コード例 #3
0
        /// <summary>Handles a CORS request that violates specification.</summary>
        /// <param name="request">
        /// The
        /// <see cref="Javax.Servlet.Http.IHttpServletRequest"/>
        /// object.
        /// </param>
        /// <param name="response">
        /// The
        /// <see cref="Javax.Servlet.Http.IHttpServletResponse"/>
        /// object.
        /// </param>
        /// <param name="filterChain">
        /// The
        /// <see cref="Javax.Servlet.IFilterChain"/>
        /// object.
        /// </param>
        /// <exception cref="System.IO.IOException"/>
        /// <exception cref="Javax.Servlet.ServletException"/>
        public void HandleInvalidCORS(IHttpServletRequest request, IHttpServletResponse response, IFilterChain filterChain)
        {
            string origin = request.GetHeader(Edu.Stanford.Nlp.Naturalli.Demo.CORSFilter.RequestHeaderOrigin);
            string method = request.GetMethod();
            string accessControlRequestHeaders = request.GetHeader(RequestHeaderAccessControlRequestHeaders);
            string message = "Invalid CORS request; Origin=" + origin + ";Method=" + method;

            if (accessControlRequestHeaders != null)
            {
                message = message + ";Access-Control-Request-Headers=" + accessControlRequestHeaders;
            }
            response.SetContentType("text/plain");
            response.SetStatus(HttpServletResponseConstants.ScForbidden);
            response.ResetBuffer();
            Log(message);
        }
コード例 #4
0
        /// <summary><inheritDoc/></summary>
        /// <exception cref="Javax.Servlet.ServletException"/>
        /// <exception cref="System.IO.IOException"/>
        protected override void DoGet(IHttpServletRequest request, IHttpServletResponse response)
        {
            if (request.GetCharacterEncoding() == null)
            {
                request.SetCharacterEncoding("utf-8");
            }
            response.SetContentType("text/json; charset=UTF-8");
            PrintWriter @out = response.GetWriter();
            string      raw  = request.GetParameter("q");

            if (raw == null || string.Empty.Equals(raw))
            {
                @out.Println("{ok:false, entailments:[], triples=[], msg=\"\"}");
            }
            else
            {
                DoGet(@out, raw);
            }
            @out.Close();
        }