<commit_before>package org.http4s
package client
package blaze

import java.net.InetSocketAddress
import java.nio.ByteBuffer
import java.util.concurrent.ExecutorService

import org.http4s.Uri.Scheme
import org.http4s.blaze.channel.nio2.ClientChannelFactory
import org.http4s.util.task
import org.http4s.blaze.pipeline.{Command, LeafBuilder}
import org.http4s.blaze.pipeline.stages.SSLStage
import org.http4s.syntax.string._

import scala.concurrent.ExecutionContext
import scala.concurrent.Future
import fs2.Task
import cats.implicits._

import scala.util.Try

private object Http1Support {
  /** Create a new [[ConnectionBuilder]]
   *
   * @param config The client configuration object
   */
  def apply(config: BlazeClientConfig, executor: ExecutorService): ConnectionBuilder[BlazeConnection] = {
    val builder = new Http1Support(config, executor)
    builder.makeClient
  }

  private val Https: Scheme = "https".ci
  private val Http: Scheme  = "http".ci
}

/** Provides basic HTTP1 pipeline building
  */
final private class Http1Support(config: BlazeClientConfig, executor: ExecutorService) {
  import Http1Support._

  private val ec = ExecutionContext.fromExecutorService(executor)
  private val sslContext = config.sslContext.getOrElse(bits.sslContext)
  private val connectionManager = new ClientChannelFactory(config.bufferSize, config.group.orNull)

////////////////////////////////////////////////////

  def makeClient(requestKey: RequestKey): Task[BlazeConnection] = getAddress(requestKey) match {
    case Right(a) => task.futureToTask(buildPipeline(requestKey, a))(ec)
    case Left(t) => Task.fail(t)
  }

  private def buildPipeline(requestKey: RequestKey, addr: InetSocketAddress): Future[BlazeConnection] = {
    connectionManager.connect(addr, config.bufferSize).map { head =>
      val (builder, t) = buildStages(requestKey)
      builder.base(head)
      head.inboundCommand(Command.Connected)
      t
    }(ec)<commit_msg>Changed blaze-client for Task utility library removal<commit_after>package org.http4s
package client
package blaze

import java.net.InetSocketAddress
import java.nio.ByteBuffer
import java.util.concurrent.ExecutorService

import org.http4s.Uri.Scheme
import org.http4s.blaze.channel.nio2.ClientChannelFactory
import org.http4s.blaze.pipeline.{Command, LeafBuilder}
import org.http4s.blaze.pipeline.stages.SSLStage
import org.http4s.syntax.string._

import scala.concurrent.ExecutionContext
import scala.concurrent.Future
import fs2.{Strategy, Task}
import cats.implicits._

import scala.util.Try

private object Http1Support {
  /** Create a new [[ConnectionBuilder]]
   *
   * @param config The client configuration object
   */
  def apply(config: BlazeClientConfig, executor: ExecutorService): ConnectionBuilder[BlazeConnection] = {
    val builder = new Http1Support(config, executor)
    builder.makeClient
  }

  private val Https: Scheme = "https".ci
  private val Http: Scheme  = "http".ci
}

/** Provides basic HTTP1 pipeline building
  */
final private class Http1Support(config: BlazeClientConfig, executor: ExecutorService) {
  import Http1Support._

  private val ec = ExecutionContext.fromExecutorService(executor)
  private val strategy = Strategy.fromExecutionContext(ec)
  private val sslContext = config.sslContext.getOrElse(bits.sslContext)
  private val connectionManager = new ClientChannelFactory(config.bufferSize, config.group.orNull)

////////////////////////////////////////////////////

  def makeClient(requestKey: RequestKey): Task[BlazeConnection] = getAddress(requestKey) match {
    case Right(a) => Task.fromFuture(buildPipeline(requestKey, a))(strategy, ec)
    case Left(t) => Task.fail(t)
  }

  private def buildPipeline(requestKey: RequestKey, addr: InetSocketAddress): Future[BlazeConnection] = {
    connectionManager.connect(addr, config.bufferSize).map { head =>
      val (builder, t) = buildStages(requestKey)
      builder.base(head)
      head.inboundCommand(Command.Connected)
      t
    }(ec)
{'fraction_non_alphanumeric': 0.11826609872212478, 'fraction_numerical': 0.006765221748935104, 'mean_word_length': 4.32977303070761, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '4741541', 'n_tokens_mistral': 1169, 'n_tokens_neox': 1153, 'n_words': 267}