<commit_before>package org.scalatra

import java.lang.{Integer => JInteger}
import javax.servlet.ServletContext
import javax.servlet.http.{HttpServletRequest, HttpServletResponse, HttpSession}

import ScalatraKernel.MultiParams

/**
 * The core DSL of a Scalatra application.
 */
trait CoreDsl {
  /**
   * The current servlet context
   */
  implicit def servletContext: ServletContext

  /**
   * The current request
   */
  implicit def request: HttpServletRequest

  /**
   * A map of the current parameters.  The map contains the head of every
   * non-empty value in `multiParams`.
   */
  def params: Map[String, String]

  /**
   * A multi-map of the current parameters.  Parameters may come from:
   * - the query string
   * - the POST body
   * - the route matchers of the currently executing route
   *
   * The map has a default value of `Seq.empty`.
   */
  def multiParams: MultiParams

  /**
   * The current response.
   */
  implicit def response: HttpServletResponse

  /**
   * Gets the content type of the current response.
   */
  def contentType = response.getContentType

  /**
   * Sets the content type of the current response.
   */
  def contentType_=(contentType: String) = response.setContentType(contentType)

  /**
   * Sets the status code of the current response.
   */
  def status(code: Int) = response.setStatus(code)

  /**
   * Sends a redirect response.
   */
  def redirect(uri: String) = {
    response.sendRedirect(uri)
    halt()
  }

  /**
   * The current HTTP session.  Creates a session if none exists.
   */
  implicit def session: HttpSession = request.getSession

  /**
   * The current HTTP session.  If none exists, None is returned.
   */
  def sessionOption: Option[HttpSession] = Option(request.getSession(false))

  /**
   * Adds a filter to run before the route.  The filter only runs if each
   * routeMatcher returns Some.  If the routeMatchers list is empty, the
   * filter runs for all routes.<commit_msg>Scaladoc that redirect now halts the action.<commit_after>package org.scalatra

import java.lang.{Integer => JInteger}
import javax.servlet.ServletContext
import javax.servlet.http.{HttpServletRequest, HttpServletResponse, HttpSession}

import ScalatraKernel.MultiParams

/**
 * The core DSL of a Scalatra application.
 */
trait CoreDsl {
  /**
   * The current servlet context
   */
  implicit def servletContext: ServletContext

  /**
   * The current request
   */
  implicit def request: HttpServletRequest

  /**
   * A map of the current parameters.  The map contains the head of every
   * non-empty value in `multiParams`.
   */
  def params: Map[String, String]

  /**
   * A multi-map of the current parameters.  Parameters may come from:
   * - the query string
   * - the POST body
   * - the route matchers of the currently executing route
   *
   * The map has a default value of `Seq.empty`.
   */
  def multiParams: MultiParams

  /**
   * The current response.
   */
  implicit def response: HttpServletResponse

  /**
   * Gets the content type of the current response.
   */
  def contentType = response.getContentType

  /**
   * Sets the content type of the current response.
   */
  def contentType_=(contentType: String) = response.setContentType(contentType)

  /**
   * Sets the status code of the current response.
   */
  def status(code: Int) = response.setStatus(code)

  /**
   * Sends a redirect response and immediately halts the current action.
   */
  def redirect(uri: String) = {
    response.sendRedirect(uri)
    halt()
  }

  /**
   * The current HTTP session.  Creates a session if none exists.
   */
  implicit def session: HttpSession = request.getSession

  /**
   * The current HTTP session.  If none exists, None is returned.
   */
  def sessionOption: Option[HttpSession] = Option(request.getSession(false))

  /**
   * Adds a filter to run before the route.  The filter only runs if each
   * routeMatcher returns Some.  If the routeMatchers list is empty, the
   * filter runs for all routes.
{'fraction_non_alphanumeric': 0.09156686626746507, 'fraction_numerical': 0.0, 'mean_word_length': 3.000998003992016, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '969542', 'n_tokens_mistral': 1148, 'n_tokens_neox': 1132, 'n_words': 415}