<commit_before>defmodule BittorrentClient.HTTPHandle.InMemoryImpl do
  @moduledoc """
  In memory implementation of the HTTPHandle behaviour for testing locally
  """
  @behaviour BittorrentClient.HTTPHandle
  require Logger

  @arch_tracker_req_url "http://tracker.archlinux.org:6969/announce?compact=1&connected_peers=&downloaded=0&info_hash=-;=e%B3i%BAQ%92%92%DD%8C%E4%20%AF%E9Q%20%DF%1E&left=547356672&next_piece_index=0&numwant=80&peer_id=-ET0001-aaaaaaaaaaaa&port=36562&uploaded=0"
  def get(@arch_tracker_req_url, _headers, _opts) do
    Logger.warn("Using #{__MODULE__} implementation for HTTPoison.get")

    # simulating response from Arch Linux servers
    resp_headers = [
      {"Server", "mimosa"},
      {"Connection", "Close"},
      {"Content-Length", "518"},
      {"Content-Type", "text/plain"}
    ]

    bento_body = %{
      "interval" => 900,
      "peers" => <<79, 95, 107, 22, 192, 180>>,
      "peers6" => ""
    }

    {status, bento_body_resp} = Bento.encode(bento_body)

    case status do
      :ok ->
        {:ok,
         %HTTPoison.Response{
           body: bento_body_resp,
           headers: resp_headers,
           status_code: 200
         }}

      _ ->
        {:error,
         %HTTPoison.Error{
           __exception__: nil,
           id: nil,
           reason: "could not bento encode #{bento_body}"
         }}
    end
  end

  def get(url, headers, opts) do
    Logger.warn("Using #{__MODULE__} implementation for HTTPoison.get")

    {:error,
     %HTTPoison.Error{
       __exception__: nil,
       id: nil,
       reason:
         "Unreckognized URL #{inspect(url)} Headers #{inspect(headers)} Opts #{inspect(opts)} (Using Mock Impl)"<commit_msg>fixed expected url<commit_after>defmodule BittorrentClient.HTTPHandle.InMemoryImpl do
  @moduledoc """
  In memory implementation of the HTTPHandle behaviour for testing locally
  """
  @behaviour BittorrentClient.HTTPHandle
  require Logger

  @arch_tracker_req_url "http://tracker.archlinux.org:6969/announce?compact=1&connected_peers=&downloaded=0&info_hash=-;=e%B3i%BAQ%92%92%DD%8C%E4%20%AF%E9Q%20%DF%1E&left=547356672&next_piece_index=0&numwant=1&peer_id=-ET0001-aaaaaaaaaaaa&port=36562&uploaded=0"
  def get(@arch_tracker_req_url, _headers, _opts) do
    Logger.warn("Using #{__MODULE__} implementation for HTTPoison.get")

    # simulating response from Arch Linux servers
    resp_headers = [
      {"Server", "mimosa"},
      {"Connection", "Close"},
      {"Content-Length", "518"},
      {"Content-Type", "text/plain"}
    ]

    bento_body = %{
      "interval" => 900,
      "peers" => <<79, 95, 107, 22, 192, 180>>,
      "peers6" => ""
    }

    {status, bento_body_resp} = Bento.encode(bento_body)

    case status do
      :ok ->
        {:ok,
         %HTTPoison.Response{
           body: bento_body_resp,
           headers: resp_headers,
           status_code: 200
         }}

      _ ->
        {:error,
         %HTTPoison.Error{
           __exception__: nil,
           id: nil,
           reason: "could not bento encode #{bento_body}"
         }}
    end
  end

  def get(url, headers, opts) do
    Logger.warn("Using #{__MODULE__} implementation for HTTPoison.get")

    {:error,
     %HTTPoison.Error{
       __exception__: nil,
       id: nil,
       reason:
         "Unreckognized URL #{inspect(url)} Headers #{inspect(headers)} Opts #{inspect(opts)} (Using InMemoryImpl)"
{'fraction_non_alphanumeric': 0.13442911652480188, 'fraction_numerical': 0.03845024948635163, 'mean_word_length': 2.9444444444444446, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4886779', 'n_tokens_mistral': 1254, 'n_tokens_neox': 1156, 'n_words': 224}