<commit_before>require "spec_helper"
require "integration/support/server"

describe HTTPI::Adapter::Curb do

  # curb is not supported on jruby
  unless RUBY_PLATFORM =~ /java/

    subject(:adapter) { :curb }

    context "http requests" do
      before :all do
        @server = IntegrationServer.run
      end

      after :all do
        @server.stop
      end

      it "sends and receives HTTP headers" do
        request = HTTPI::Request.new(@server.url + "x-header")
        request.headers["X-Header"] = "HTTPI"

        response = HTTPI.get(request, adapter)
        expect(response.body).to include("HTTPI")
      end

      it "it supports headers with multiple values" do
        request = HTTPI::Request.new(@server.url + "cookies")

        response = HTTPI.get(request, adapter)
        cookies = ["cookie1=chip1; path=/", "cookie2=chip2; path=/"]
        expect(response.headers["Set-Cookie"]).to eq(cookies)
      end

      it "executes GET requests" do
        response = HTTPI.get(@server.url, adapter)
        expect(response.body).to eq("get")
        expect(response.headers["Content-Type"]).to eq("text/plain")
      end

      it "executes POST requests" do
        response = HTTPI.post(@server.url, "<some>xml</some>", adapter)
        expect(response.body).to eq("post")
        expect(response.headers["Content-Type"]).to eq("text/plain")<commit_msg>Add integration test for curb + read_timeout<commit_after>require "spec_helper"
require "integration/support/server"

describe HTTPI::Adapter::Curb do

  # curb is not supported on jruby
  unless RUBY_PLATFORM =~ /java/

    subject(:adapter) { :curb }

    context "http requests" do
      before :all do
        @server = IntegrationServer.run
      end

      after :all do
        @server.stop
      end

      it "sends and receives HTTP headers" do
        request = HTTPI::Request.new(@server.url + "x-header")
        request.headers["X-Header"] = "HTTPI"

        response = HTTPI.get(request, adapter)
        expect(response.body).to include("HTTPI")
      end

      it "it supports headers with multiple values" do
        request = HTTPI::Request.new(@server.url + "cookies")

        response = HTTPI.get(request, adapter)
        cookies = ["cookie1=chip1; path=/", "cookie2=chip2; path=/"]
        expect(response.headers["Set-Cookie"]).to eq(cookies)
      end

      it "it supports read timeout" do
        require "curb"

        request = HTTPI::Request.new(@server.url + "timeout")
        request.read_timeout = 0.5 # seconds

        expect do
          puts HTTPI.get(request, adapter).inspect
        end.to raise_exception(Curl::Err::TimeoutError)
      end

      it "executes GET requests" do
        response = HTTPI.get(@server.url, adapter)
        expect(response.body).to eq("get")
        expect(response.headers["Content-Type"]).to eq("text/plain")
      end

      it "executes POST requests" do
        response = HTTPI.post(@server.url, "<some>xml</some>", adapter)
        expect(response.body).to eq("post")
        expect(response.headers["Content-Type"]).to eq("text/plain")
{'fraction_non_alphanumeric': 0.1291155584247902, 'fraction_numerical': 0.0032278889606197547, 'mean_word_length': 2.676156583629893, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '4912874', 'n_tokens_mistral': 964, 'n_tokens_neox': 923, 'n_words': 224}