samvera / questioning_authority

Question your authorities
Other
54 stars 30 forks source link

Library of Congress now redirecting HTTP requests to HTTPS #320

Closed mbklein closed 3 years ago

mbklein commented 3 years ago

LOC recently starting requiring https: for all id.loc.gov requests. (Identifiers are still http:, but if you access the site using http:, you’ll get a 302 Moved Permanently redirect to the https: version). If QA isn’t already respecting redirects (and probably even if it is), it should probably be updated to use https: on all LOC calls.

elrayle commented 3 years ago

-- Copied from Slack comments by elrayle on dev channel 2020-08-14 9:10am ET

I’m not sure the change for LOC in QA was all that was needed. I can fetch by id, but search returns 0 results.

The current URL generated is…

https://id.loc.gov/search/?q=History--&q=cs%3Ahttps%3A%2F%2Fid.loc.gov%2Fauthorities%2Fsubjects&format=json

A URL that returns results is…

https://id.loc.gov/search/?q=History--&format=json

The code that produces the first URL has been around for at least 4 years. I assume the purpose is to limit the search to subjects.

Alright, I figured it out… the URL should be…

https://id.loc.gov/search/?q=cs:http://id.loc.gov/authorities/subjects&q=History--&format=json

Notice the q=cs URL is http instead of https.

The cs URL is generated in Qa::Authorities::LocSubauthority.