<commit_before>/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.wiztools.restclient;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Enumeration;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author subwiz
 */
public class TraceServlet extends HttpServlet {
    private void process(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
        response.setContentType("text/plain");
        PrintWriter out = response.getWriter();
        out.println("**RESTClient TraceServlet**");
        
        out.println("\n*Method*");
        out.println("\t" + request.getMethod());
        
        out.println("\n*Path Info*");
        out.println("\t" + request.getPathInfo());
        
        out.println("\n*Headers*");
        Enumeration eHeaders = request.getHeaderNames();
        while(eHeaders.hasMoreElements()){
            String headerName = (String)eHeaders.nextElement();
            String headerValue = request.getHeader(headerName);
            headerValue = headerValue.replaceAll("\n", "\n\t");
            out.println("\t" + headerName + ": " + request.getHeader(headerName));
        }
        
        out.println("\n*Query String*");
        out.println("\t" + request.getQueryString());
        
        out.println("\n*Parameters*");
        Enumeration eParams = request.getParameterNames();<commit_msg>TraceServlet now specifies the charset in response.<commit_after>/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.wiztools.restclient;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Enumeration;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author subwiz
 */
public class TraceServlet extends HttpServlet {
    private void process(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
        response.setContentType("text/plain; charset=UTF-8");
        PrintWriter out = response.getWriter();
        out.println("**RESTClient TraceServlet**");
        
        out.println("\n*Method*");
        out.println("\t" + request.getMethod());
        
        out.println("\n*Path Info*");
        out.println("\t" + request.getPathInfo());
        
        out.println("\n*Headers*");
        Enumeration eHeaders = request.getHeaderNames();
        while(eHeaders.hasMoreElements()){
            String headerName = (String)eHeaders.nextElement();
            String headerValue = request.getHeader(headerName);
            headerValue = headerValue.replaceAll("\n", "\n\t");
            out.println("\t" + headerName + ": " + request.getHeader(headerName));
        }
        
        out.println("\n*Query String*");
        out.println("\t" + request.getQueryString());
        
        out.println("\n*Parameters*");
        Enumeration eParams = request.getParameterNames();
{'fraction_non_alphanumeric': 0.12977777777777777, 'fraction_numerical': 0.0002962962962962963, 'mean_word_length': 3.1576354679802954, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6716733', 'n_tokens_mistral': 893, 'n_tokens_neox': 891, 'n_words': 184}