Provides CGI Gateway service. @param req HttpServletRequest passed in by servlet container @param res HttpServletResponse passed in by servlet container @exception ServletException if a servlet-specific exception occurs @exception IOException if a read/write exception occurs
(HttpServletRequest req, HttpServletResponse res)
| 552 | * @exception IOException if a read/write exception occurs |
| 553 | */ |
| 554 | @Override |
| 555 | protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { |
| 556 | |
| 557 | CGIEnvironment cgiEnv = new CGIEnvironment(req, getServletContext()); |
| 558 | |
| 559 | if (cgiEnv.isValid()) { |
| 560 | CGIRunner cgi = new CGIRunner(cgiEnv.getCommand(), cgiEnv.getEnvironment(), cgiEnv.getWorkingDirectory(), |
| 561 | cgiEnv.getParameters()); |
| 562 | |
| 563 | if (Method.POST.equals(req.getMethod())) { |
| 564 | cgi.setInput(req.getInputStream()); |
| 565 | } |
| 566 | cgi.setResponse(res); |
| 567 | cgi.run(); |
| 568 | } else { |
| 569 | res.sendError(404); |
| 570 | } |
| 571 | |
| 572 | if (log.isTraceEnabled()) { |
| 573 | String[] cgiEnvLines = cgiEnv.toString().split(System.lineSeparator()); |
| 574 | for (String cgiEnvLine : cgiEnvLines) { |
| 575 | log.trace(cgiEnvLine); |
| 576 | } |
| 577 | |
| 578 | printServletEnvironment(req); |
| 579 | } |
| 580 | } |
| 581 | |
| 582 | |
| 583 | @Override |
no test coverage detected