Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve chained redirections in DOIs #188

Merged
merged 2 commits into from Dec 6, 2018
Merged

Resolve chained redirections in DOIs #188

merged 2 commits into from Dec 6, 2018

Conversation

@Xarthisius
Copy link
Collaborator

Xarthisius commented Dec 6, 2018

DOI often points to a location that returns 30x code, that potentially resolves to another location returning 30x... A good example:

$ curl -s -IL https://hdl.handle.net/1902.1/22315  |grep "HTTP\|Location"
HTTP/1.1 303 See Other
Location: http://thedata.harvard.edu/dvn/study?globalId=hdl:1902.1/22315
HTTP/1.1 302 Found
Location: https://thedata.harvard.edu/dvn/study?globalId=hdl:1902.1/22315
HTTP/1.1 302 Found
Location: https://dataverse.harvard.edu/dataset.xhtml?persistentId=hdl:1902.1/22315
HTTP/1.1 200 OK

This PR tries to resolve DOI until 200 is reached. It also uses HEAD instead of GET, which should be more efficient in case DOI resolves with a big object.

Testing:

  1. Try as many different DOIs as you can think of.
@codecov

This comment has been minimized.

Copy link

codecov bot commented Dec 6, 2018

Codecov Report

Merging #188 into master will increase coverage by 0.07%.
The diff coverage is 88.88%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #188      +/-   ##
==========================================
+ Coverage   84.96%   85.03%   +0.07%     
==========================================
  Files          34       34              
  Lines        2075     2085      +10     
==========================================
+ Hits         1763     1773      +10     
  Misses        312      312
Impacted Files Coverage Δ
server/rest/repository.py 100% <100%> (ø) ⬆️
server/lib/resolvers.py 89.06% <88%> (+2.02%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9509168...d922801. Read the comment docs.

@Xarthisius Xarthisius requested a review from craig-willis Dec 6, 2018
Copy link

craig-willis left a comment

Looks good. As you noted, this solves the problem I was seeing with doi:10.7910/DVN/29911. Not sure where to put this, but I noticed that the Dashboard register isn't stripping whitespace during lookup. If I input " https://hdl.handle.net/1902.1/22315" instead of "https://hdl.handle.net/1902.1/22315", lookup fails.

@Xarthisius Xarthisius merged commit 26cad07 into master Dec 6, 2018
3 checks passed
3 checks passed
ci/circleci Your tests passed on CircleCI!
Details
codecov/patch 88.88% of diff hit (target 84.96%)
Details
codecov/project 85.03% (+0.07%) compared to 9509168
Details
@Xarthisius Xarthisius deleted the issue_187 branch Dec 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.