<commit_before>package play.core.server.servlet25

import java.util.Arrays
import java.util.concurrent._

import javax.servlet.http.{ Cookie => ServletCookie, _ }

import play.core._
import play.api._
import play.api.mvc._
import play.api.libs.iteratee._
import play.api.libs.iteratee.Input._
import play.api.libs.concurrent._

import scala.collection.JavaConverters._

private[servlet25] trait Helpers {

  def getPlayHeaders(request: HttpServletRequest): Headers = {
//
//    import java.util.Collections
//
//    val headers: Map[String, Seq[String]] = request.getHeaderNames.asScala.map {
//      key =>
//        key.toString.toUpperCase -> {
//          // /!\ It very important to COPY headers from request enumeration
//          val truc = Collections.list(request.getHeaders(key.toString)).asScala
//          val machin: Seq[String] = truc.map { t =>
//          	t.toString
//          }
//          truc
//        }
//    }.toMap
//
//    new Headers {
//
//      def getAll(key: String) = headers.get(key.toUpperCase).flatten.toSeq
//      def keys = headers.keySet
//      override def toString = headers.map {
//        case (k, v) => {
//          k + ": " + v.mkString(", ")
//        }
//      }.mkString("\n  ")
//    }
    null
  }

  def getPlayCookies(request: HttpServletRequest): Cookies = {
//
//    val cookies: Map[String, play.api.mvc.Cookie] = request.getCookies match {
//      case null => Map.empty
//      case _ => Arrays.asList(request.getCookies: _*).asScala.map { c =>
//        c.getName -> play.api.mvc.Cookie(
//          c.getName, c.getValue, c.getMaxAge, Option(c.getPath).getOrElse("/"), Option(c.getDomain), c.getSecure, c.isHttpOnly)
//      }.toMap
//    }
//
//    new Cookies {
//      def get(name: String) = cookies.get(name)
//      override def toString = cookies.toString
//    }
    null
  }

  def getServletCookies(flatCookie: String): Seq[ServletCookie] = {
//    Cookies.decode(flatCookie).map {
//      pCookie =>
//        val sc = new ServletCookie(pCookie.name, pCookie.value)
//        pCookie.domain.map(sc.setDomain(_))
//        sc.setHttpOnly(pCookie.httpOnly)
//        sc.setMaxAge(pCookie.maxAge)
//        sc.setPath(pCookie.path)
//        sc.setSecure(pCookie.secure)
//        sc
//    }
    null
  }
}
<commit_msg>WIP on Servlet 2.5 implementation<commit_after>package play.core.server.servlet25

import java.util.Arrays
import java.util.concurrent._

import javax.servlet.http.{ Cookie => ServletCookie, _ }

import play.core._
import play.api._
import play.api.mvc._
import play.api.libs.iteratee._
import play.api.libs.iteratee.Input._
import play.api.libs.concurrent._

import scala.collection.JavaConverters._

private[servlet25] trait Helpers {

  def getPlayHeaders(request: HttpServletRequest): Headers = {

    import java.util.Collections

      val headerNames = request.getHeaderNames.asScala
      
      val allHeaders: Map[String, Seq[String]] = headerNames.map {
        key =>
          key.toString.toUpperCase -> {
            // /!\ It very important to COPY headers from request enumeration
            val headers = Collections.list(request.getHeaders(key.toString)).asScala
            headers.map { t => t.toString }
          }
      }.toMap

    new Headers {

      def getAll(key: String) = allHeaders.get(key.toUpperCase).flatten.toSeq
      def keys = allHeaders.keySet
      override def toString = allHeaders.map {
        case (k, v) => {
          k + ": " + v.mkString(", ")
        }
      }.mkString("\n  ")
    }
    null
  }

  def getPlayCookies(request: HttpServletRequest): Cookies = {

    val cookies: Map[String, play.api.mvc.Cookie] = request.getCookies match {
      case null => Map.empty
      case _ => Arrays.asList(request.getCookies: _*).asScala.map { c =>
        c.getName -> play.api.mvc.Cookie(
          c.getName, c.getValue, c.getMaxAge, Option(c.getPath).getOrElse("/"), Option(c.getDomain), c.getSecure)
      }.toMap
    }

    new Cookies {
      def get(name: String) = cookies.get(name)
      override def toString = cookies.toString
    }
  }

  def getServletCookies(flatCookie: String): Seq[ServletCookie] = {
    Cookies.decode(flatCookie).map {
      pCookie =>
        val sc = new ServletCookie(pCookie.name, pCookie.value)
        pCookie.domain.map(sc.setDomain(_))
        sc.setMaxAge(pCookie.maxAge)
        sc.setPath(pCookie.path)
        sc.setSecure(pCookie.secure)
        sc
    }
  }
}

{'fraction_non_alphanumeric': 0.1393884892086331, 'fraction_numerical': 0.0022482014388489208, 'mean_word_length': 2.360271903323263, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 23, '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': '824364', 'n_tokens_mistral': 1477, 'n_tokens_neox': 1434, 'n_words': 271}