code4lib / ruby-oai

a Ruby library for building OAI-PMH clients and servers
MIT License
62 stars 42 forks source link

Allow Faraday 2.x #91

Closed jrochkind closed 2 years ago

jrochkind commented 2 years ago

Closes #89

Allow Faraday 2.x, by switching from faraday-middleware to the new faraday_follow-redirects gem

By switching from faraday-middleware to the new faraday_follow-redirects gem

The new gem is compatible with both faraday 1 and 2, while faraday-middleware (which included a redirect middleware) has a gemspec that does not allow faraday 2.

I manually tested on faraday 1 by editing Gemfile locally -- it passes. I'm not sure if we want to regularly/automated test on both faraday 1 and 2? Right now we have no automated CI at all, see #87

Strip invalid chars without raising encoding exception regardless of encoding

On upgrade to faraday 2, HTTP responses can come back in specific encodings per the content-type of response. This effected one of our tests, that is using a live query to google.com (probably not a great idea), that comes back ISO-8859-1. But it actually would have failed if UTF-8 too, because we're trying to gsub some intentionally illegal bytes. I am not sure if the approach to encoding is totally sound in this gem in general -- XML does have to be Unicode legally, but can be UTF-8 or -16, this strip routine may be assuming UTF8? But not actually properly making it with the ruby UTF8 encoding?

But this is just an attempt to change as little as possible leaving as backward compat as possible while passing tests in faraday 2; and resolving the specific problem of the strip_invalid_utf_8_chars failing when response comes back with ruby encoding tag from faraday 2.

jrochkind commented 2 years ago

@mcritchlow and @orangewolf anyone interested in reviewing? If I don't hear from anyone, I may do a merge myself.

jrochkind commented 2 years ago

Thanks @orangewolf!