/** * Output the body information. */ private static void outputBody(FileWriter fw, LoggingHttpServletRequestWrapper req) throws IOException { // Get the body size int leng = req.getContentLength(); // Do nothing if there is no body if (leng <= 0) return; // Buffer to read byte rbuf[] = new byte[leng]; // Put data InputStream in = req.getInputStream(); if (in.read(rbuf, 0, leng) > 0) { // Output data outputBinary(fw, rbuf); } }
/** * Display the request header. */ private static void outputHeaders(FileWriter fw, LoggingHttpServletRequestWrapper req) throws IOException { // Get the header Enumeration reqHeaderNum = req.getHeaderNames(); // Do nothing if there is no header if (reqHeaderNum == null) { fw.write("No headers" + "\n"); return; } // Repeat the header element while (reqHeaderNum.hasMoreElements()) { // Get the key String key = (String) reqHeaderNum.nextElement(); // Output the header information outputHeaderElements(fw, req, key); } }
/** * Output header information. */ private static void outputHeaderElements(FileWriter fw, LoggingHttpServletRequestWrapper req, String key) throws IOException { // Output the header information Enumeration e = req.getHeaders(key); String keyname = key; while (e.hasMoreElements()) { fw.write(keyname + " : " + e.nextElement() + "\n"); // Output key name only for the first time keyname = " "; } }
fw.write("Client IP Address : " + req.getRemoteAddr() + "\n"); fw.write("Client FQDN : " + req.getRemoteHost() + "\n"); fw.write("Body size : " + req.getContentLength() + "\n");
LoggingHttpServletRequestWrapper wrapper = new LoggingHttpServletRequestWrapper(req); req = wrapper; wrapper.doReadBody();
fw.write("Client IP Address : " + req.getRemoteAddr() + "\n"); fw.write("Client FQDN : " + req.getRemoteHost() + "\n"); fw.write("Body size : " + req.getContentLength() + "\n");
LoggingHttpServletRequestWrapper wrapper = new LoggingHttpServletRequestWrapper(req); req = wrapper; wrapper.doReadBody();
/** * Output the body information. */ private static void outputBody(FileWriter fw, LoggingHttpServletRequestWrapper req) throws IOException { // Get the body size int leng = req.getContentLength(); // Do nothing if there is no body if (leng <= 0) return; // Buffer to read byte rbuf[] = new byte[leng]; // Put data InputStream in = req.getInputStream(); if (in.read(rbuf, 0, leng) > 0) { // Output data outputBinary(fw, rbuf); } }
/** * Output header information. */ private static void outputHeaderElements(FileWriter fw, LoggingHttpServletRequestWrapper req, String key) throws IOException { // Output the header information Enumeration e = req.getHeaders(key); String keyname = key; while (e.hasMoreElements()) { fw.write(keyname + " : " + e.nextElement() + "\n"); // Output key name only for the first time keyname = " "; } }
/** * Display the request header. */ private static void outputHeaders(FileWriter fw, LoggingHttpServletRequestWrapper req) throws IOException { // Get the header Enumeration reqHeaderNum = req.getHeaderNames(); // Do nothing if there is no header if (reqHeaderNum == null) { fw.write("No headers" + "\n"); return; } // Repeat the header element while (reqHeaderNum.hasMoreElements()) { // Get the key String key = (String) reqHeaderNum.nextElement(); // Output the header information outputHeaderElements(fw, req, key); } }