Skip to content

Conversation

@ojab
Copy link
Contributor

@ojab ojab commented Jan 13, 2022

httpstat.us switched to HTTPS and returning 301 for plain HTTP and now
there is no X-Powered-By header, use HTTPS + Server header instead.

http.rb >= 5.0.2 expects stream result to be in the proper encoding after httprb/http#653, force encoding in Streamer.

@ojab ojab force-pushed the https_httpstat.us branch from 772c7c1 to 1055b45 Compare January 13, 2022 02:11
```
curl -i http://httpstat.us/200
HTTP/1.1 301 Moved Permanently
Content-Type: text/html; charset=UTF-8
Location: https://httpstat.us/200
Date: Thu, 13 Jan 2022 02:06:09 GMT
Content-Length: 0
```
@ojab ojab force-pushed the https_httpstat.us branch from 1055b45 to 6454c09 Compare January 13, 2022 02:15
@ojab ojab changed the title Use https://httpstat.us instead of plain http in specs Use https://httpbin.org instead ofhttps://httpstat.us in specs Jan 13, 2022
@ojab
Copy link
Contributor Author

ojab commented Jan 13, 2022

Ok, apparently httpstat.us made some changes a month ago and now there is no Content-Length header.
httpbin.org doesn't return status message, only status code.

I guess we can run https://github.com/aaronpowell/httpstatus/pkgs/container/httpstatus in GHA, but it would complicate local development.

Any hints what's the desired solution? I can try to find another service that could be used or file a bug for https://github.com/aaronpowell/httpstatus, but it's fragile anyway.

@ojab
Copy link
Contributor Author

ojab commented Jan 13, 2022

Filed an issue aaronpowell/httpstatus#105

After httprb/http#653 http.rb doesn't force
encode stream result to be in the correct encoding
@ojab ojab changed the title Use https://httpbin.org instead ofhttps://httpstat.us in specs Make CI green again Jan 14, 2022
@ojab
Copy link
Contributor Author

ojab commented Jan 14, 2022

httpstat.us issue with missing Content-Length is fixed, also fixed encoding issue in http.rb adapter. CI run in my fork is green https://github.com/ojab/webmock/actions/runs/1696366879

@bblimke
Copy link
Owner

bblimke commented Jan 23, 2022

@ojab I wonder why the builds fail on Ruby 3.0.

@ojab
Copy link
Contributor Author

ojab commented Jan 23, 2022

spec/acceptance/async_http_client/async_http_client_spec.rb hangs 😿
I'm gonna take a look at it this week.

RSpec tries to lock a mutex for `let` evaluation and Async reactor
tries to block itself and hangs on select
@ojab
Copy link
Contributor Author

ojab commented Feb 10, 2022

Okay, looks like Async is incompatible with RSpec in ruby >= 3.0.

require 'async'
require 'async/http'

RSpec.describe 'qwe' do
  let(:endpoint) { Async::HTTP::Endpoint.parse('http://www.example.com') }
  let(:protocol) { Async::HTTP::Protocol::HTTP10 }
  let(:requests_count) { 1 }

  subject do
    puts "In subject"
    responses = {}
    Async do |task|
      puts "In Async"
      Async::HTTP::Client.open(endpoint, protocol) do |client|
        puts "In Client"
        requests_count.times do |index|
          response = client.get "/foo#{index}"
          responses[index] = response_to_hash(response)
        end
      end
    end
    responses
  end

  specify do
    puts "Running!"
    expect(subject).not_to be_nil
  end
end

this spec in empty project with Gemfile

# frozen_string_literal: true

source "https://rubygems.org"

# gem "rails"

gem 'async-http'
gem 'rspec'

hangs the same way. async-2.0 switched to fiber scheduler and dropped ruby<3.0 support, so I don't see value in reporting it.

Anyway, not a webmock bug, workarounded by replacing let with let! in the last commit.

@ojab
Copy link
Contributor Author

ojab commented Feb 10, 2022

And some RSpec changes broken two specs, fixed in the last commit.
CI in my fork is green https://github.com/ojab/webmock/actions/runs/1824337706 with all the changes.

@bblimke bblimke merged commit d5141ca into bblimke:master Aug 2, 2022
@bblimke
Copy link
Owner

bblimke commented Aug 2, 2022

Thank you @ojab

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants