MCPcopy Create free account
hub / github.com/apache/tomcat / processSSI

Method processSSI

java/org/apache/catalina/ssi/SSIServlet.java:187–224  ·  view source on GitHub ↗

Process SSI directives in the given resource. @param req the HTTP servlet request @param res the HTTP servlet response @param resource the URL of the resource to process @throws IOException if an I/O error occurs

(HttpServletRequest req, HttpServletResponse res, URL resource)

Source from the content-addressed store, hash-verified

185 * @throws IOException if an I/O error occurs
186 */
187 protected void processSSI(HttpServletRequest req, HttpServletResponse res, URL resource) throws IOException {
188 SSIExternalResolver ssiExternalResolver = new SSIServletExternalResolver(getServletContext(), req, res,
189 isVirtualWebappRelative, debug, inputEncoding);
190 SSIProcessor ssiProcessor = new SSIProcessor(ssiExternalResolver, debug, allowExec);
191 PrintWriter printWriter;
192 StringWriter stringWriter = null;
193 if (buffered) {
194 stringWriter = new StringWriter();
195 printWriter = new PrintWriter(stringWriter);
196 } else {
197 printWriter = res.getWriter();
198 }
199
200 URLConnection resourceInfo = resource.openConnection();
201 InputStream resourceInputStream = resourceInfo.getInputStream();
202 String encoding = resourceInfo.getContentEncoding();
203 if (encoding == null) {
204 encoding = inputEncoding;
205 }
206 InputStreamReader isr;
207 if (encoding == null) {
208 isr = new InputStreamReader(resourceInputStream);
209 } else {
210 isr = new InputStreamReader(resourceInputStream, encoding);
211 }
212
213 try (BufferedReader bufferedReader = new BufferedReader(isr)) {
214 long lastModified = ssiProcessor.process(bufferedReader, resourceInfo.getLastModified(), printWriter);
215 if (lastModified > 0) {
216 res.setDateHeader("last-modified", lastModified);
217 }
218 if (stringWriter != null) {
219 printWriter.flush();
220 String text = stringWriter.toString();
221 res.getWriter().write(text);
222 }
223 }
224 }
225}

Callers 1

requestHandlerMethod · 0.95

Calls 10

processMethod · 0.95
getServletContextMethod · 0.65
getWriterMethod · 0.65
getInputStreamMethod · 0.65
getLastModifiedMethod · 0.65
setDateHeaderMethod · 0.65
flushMethod · 0.65
toStringMethod · 0.65
writeMethod · 0.65
openConnectionMethod · 0.45

Tested by

no test coverage detected