Esempio n. 1
0
 protected override void doPost(HttpServletRequest request, HttpServletResponse response)
 {
     request.setCharacterEncoding("UTF-8");
     Message.Message newMessage = new Message.Message(request.getParameter("title"),
                                                      request.getParameter("handle"),
                                                      request.getParameter("message"));
     newMessage.date = DateTime.Now;
     Message.Message.messageList.Insert(0, newMessage);
     response.sendRedirect("/testbbs/ShowBBS");
 }
Esempio n. 2
0
        protected override void doPost(HttpServletRequest request, HttpServletResponse response)
        {
            request.setCharacterEncoding("Shift_JIS");
            response.setContentType("text/plain; charset=Shift_JIS");
            StreamWriter output = response.getWriter();

            foreach (Part part in request.getParts())
            {
                output.WriteLine("name.." + part.getName());
                foreach (String headerName in part.getHeaderNames())
                {
                    output.WriteLine(headerName + "=" + part.getHeader(headerName));
                }
                output.WriteLine("Content-Type.." + part.getContentType());
                output.WriteLine("Name.." + part.getName() + "/size.." + part.getSize());
                StreamReader reader = new StreamReader(part.getInputStream(), Encoding.GetEncoding("Shift_JIS"));
                int          ch;
                while ((ch = reader.Read()) >= 0)
                {
                    output.Write((char)(ch & 0xffff));
                }
                reader.Close();
                output.WriteLine("\n==================================");
            }
            output.WriteLine("text_name=" + request.getParameter("text_name"));
        }
Esempio n. 3
0
        public override void service(ServletRequest request, ServletResponse response)

        {
            HttpServletRequest  req = (HttpServletRequest)request;
            HttpServletResponse res = (HttpServletResponse)response;

            res.setContentType("text/html");

            if (_path == null)
            {
                res.sendError(HttpServletResponse.SC_FORBIDDEN);
                return;
            }

            string fileName = req.getParameter("file");

            if (fileName != null)
            {
                printFile(fileName, req, res);
                return;
            }

            PrintWriter @out = res.getWriter();

            @out.println("<pre>");

            printPath(@out, _path, 0);

            @out.println("</pre>");
        }
Esempio n. 4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void handle(String target, org.eclipse.jetty.server.Request baseRequest, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOException
            public override void Handle(string target, Request baseRequest, HttpServletRequest request, HttpServletResponse response)
            {
                PrintWriter @out = response.Writer;

                response.ContentType = MimeTypes.Type.APPLICATION_JSON.asString();

                string path         = request.PathInfo;
                string expectedPath = string.format(KubernetesResolver.KubernetesClient.PATH, ExpectedNamespace);

                string labelSelector = request.getParameter("labelSelector");
                string auth          = request.getHeader(HttpHeader.AUTHORIZATION.name());
                string expectedAuth  = "Bearer " + ExpectedAuthToken;

                if (!expectedPath.Equals(path))
                {
                    response.Status = HttpServletResponse.SC_BAD_REQUEST;
                    @out.println(Fail("Unexpected path: " + path));
                }
                else if (!ExpectedLabelSelector.Equals(labelSelector))
                {
                    response.Status = HttpServletResponse.SC_BAD_REQUEST;
                    @out.println(Fail("Unexpected labelSelector: " + labelSelector));
                }
                else if (!expectedAuth.Equals(auth))
                {
                    response.Status = HttpServletResponse.SC_BAD_REQUEST;
                    @out.println(Fail("Unexpected auth header value: " + auth));
                }
                else if (!"GET".Equals(request.Method))
                {
                    response.Status = HttpServletResponse.SC_BAD_REQUEST;
                    @out.println(Fail("Unexpected method: " + request.Method));
                }
                else
                {
                    response.Status = HttpServletResponse.SC_OK;
                    if (!string.ReferenceEquals(Body, null))
                    {
                        @out.println(Body);
                    }
                }

                baseRequest.Handled = true;
            }
Esempio n. 5
0
        protected override void doGet(HttpServletRequest request, HttpServletResponse response)
        {
            response.setContentType("text/plain; charset=UTF-8");
            StreamWriter output = response.getWriter();

            String postalCode = request.getParameter("postalCode");
            String ret;

            if (postalCode.Equals("162-0846"))
            {
                ret = "東京都新宿区市谷左内町";
            }
            else if (postalCode.Equals("100-0014"))
            {
                ret = "東京都千代田区永田町";
            }
            else
            {
                ret = "不明";
            }
            response.setStatus(HttpServletResponse.SC_OK);
            output.WriteLine(ret);
        }
 public override string getParameter(String name)
 {
     return(_request.getParameter(name));
 }