<commit_before>/*
    Copyright (c) 2007 Redstone Handelsbolag

    This library is free software; you can redistribute it and/or modify it under the terms
    of the GNU Lesser General Public License as published by the Free Software Foundation;
    either version 2.1 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
    without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    See the GNU Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License along with this
    library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
    Boston, MA  02111-1307  USA
*/

package redstone.xmlrpc;

import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *  Servlet that publishes an XmlRpcServer in a web server.
 *
 *  @author <NAME>
 */

public class XmlRpcServlet extends HttpServlet
{
    /**
     *  Initializes the servlet by instantiating the XmlRpcServer that will
     *  hold all invocation handlers and processors. The servlet configuration
     *  is read to see if the XML-RPC responses generated should be streamed
     *  immediately to the resonse (non-compliant) or if they should be buffered
     *  before being sent (compliant, since then the Content-Length header may
     *  be set, as stipulated by the XML-RPC specification).
     */

    public void init( ServletConfig config ) throws ServletException
    {
        String contentType = config.getInitParameter( "contentType" );
        String streamMessages = config.getInitParameter( "streamMessages" );
        
        if ( streamMessages != null && streamMessages.equals( "1" ) )
        {
            this.streamMessages = true;
        }
        
        if ( contentType != null && contentType.startsWith( "text/javascript+json" ) )
        {
            contentType = "text/javascript+json";
            server = new XmlRpcServer( new XmlRpcJsonSerializer() );
        }
        else
        {
            contentType = "text/xml";
            server = new XmlRpcServer();
        }
        
        contentType += "; charset=" + XmlRpcMessages.getString( "XmlRpcServlet.Encoding" );
    }

    
    /**<commit_msg>Fixed bug with local contentType variable hiding member variable.<commit_after>/*
    Copyright (c) 2007 <NAME>

    This library is free software; you can redistribute it and/or modify it under the terms
    of the GNU Lesser General Public License as published by the Free Software Foundation;
    either version 2.1 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
    without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    See the GNU Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License along with this
    library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
    Boston, MA  02111-1307  USA
*/

package redstone.xmlrpc;

import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *  Servlet that publishes an XmlRpcServer in a web server.
 *
 *  @author <NAME>
 */

public class XmlRpcServlet extends HttpServlet
{
    /**
     *  Initializes the servlet by instantiating the XmlRpcServer that will
     *  hold all invocation handlers and processors. The servlet configuration
     *  is read to see if the XML-RPC responses generated should be streamed
     *  immediately to the resonse (non-compliant) or if they should be buffered
     *  before being sent (compliant, since then the Content-Length header may
     *  be set, as stipulated by the XML-RPC specification).
     */

    public void init( ServletConfig config ) throws ServletException
    {
        String contentType = config.getInitParameter( "contentType" );
        String streamMessages = config.getInitParameter( "streamMessages" );
        
        if ( streamMessages != null && streamMessages.equals( "1" ) )
        {
            this.streamMessages = true;
        }
        
        if ( contentType != null && contentType.startsWith( "text/javascript+json" ) )
        {
            this.contentType = "text/javascript+json";
            server = new XmlRpcServer( new XmlRpcJsonSerializer() );
        }
        else
        {
            this.contentType = "text/xml";
            server = new XmlRpcServer();
        }
        
        this.contentType += "; charset=" + XmlRpcMessages.getString( "XmlRpcServlet.Encoding" );
    }

    
    /**
{'fraction_non_alphanumeric': 0.07211723871962977, 'fraction_numerical': 0.008098727342846125, 'mean_word_length': 2.87089552238806, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '2260740', 'n_tokens_mistral': 1381, 'n_tokens_neox': 1310, 'n_words': 525}