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

Re-add wildcard types and modify checks for acceptable types. #1977

Merged
merged 3 commits into from Mar 15, 2022

Conversation

whikloj
Copy link
Collaborator

@whikloj whikloj commented Mar 3, 2022

JIRA Ticket: https://fedora-repository.atlassian.net/browse/FCREPO-3810

What does this Pull Request do?

Re-adds wildcards to the Jersey endpoints otherwise Jersey rejects Accept headers that aren't in the list (which are all RDF types and text/plain and text/html).

Also makes HEAD requests respond the same as a GET request.

How should this be tested?

Before this PR.
Put up a binary that is not text/plain or text/html (you can put up plain text and claim it is application/pdf though)
ie.

> curl -ufedoraAdmin:fedoraAdmin -XPUT -H"Content-type: application/pdf" --data-binary "Some fake binary" http://localhost:8080/rest/test_binary

HTTP/1.1 201 Created

Do a HEAD request to see the Content-type is set correctly.

> curl -I -ufedoraAdmin:fedoraAdmin http://localhost:8080/rest/test_binary

HTTP/1.1 200 OK
...
Content-Type: application/pdf
...

Now do a HEAD and/or GET request using that mimetype with the Accept header.

> curl -I -ufedoraAdmin:fedoraAdmin http://localhost:8080/rest/test_binary -H"Accept: application/pdf"

HTTP/1.1 406 Not Acceptable
> curl -i -ufedoraAdmin:fedoraAdmin http://localhost:8080/rest/test_binary -H"Accept: application/pdf"

HTTP/1.1 406 Not Acceptable

Pull in this PR, rebuild and try getting them again.

> curl -I -ufedoraAdmin:fedoraAdmin http://localhost:8080/rest/test_binary -H"Accept: application/pdf"             

HTTP/1.1 200 OK
> curl -i -ufedoraAdmin:fedoraAdmin http://localhost:8080/rest/test_binary -H"Accept: application/pdf"             

HTTP/1.1 200 OK

But it still fails if the type is not compatible.

> curl -i -ufedoraAdmin:fedoraAdmin http://localhost:8080/rest/test_binary/fcr:metadata -H"Accept: application/pdf"

HTTP/1.1 406 Not Acceptable
> curl -i -ufedoraAdmin:fedoraAdmin http://localhost:8080/rest/test_binary -H"Accept: image/tiff"                  

HTTP/1.1 406 Not Acceptable

Interested parties

Tag (@ mention) interested parties or, if unsure, @fcrepo/committers

dbernstein
dbernstein previously approved these changes Mar 7, 2022
Copy link
Contributor

@dbernstein dbernstein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work @whikloj. Code looks good and it works as advertised.

bbpennel
bbpennel previously approved these changes Mar 11, 2022
Copy link
Collaborator

@bbpennel bbpennel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me and is functioning as I would expect for GET and HEAD requests. The only thing I am wondering is if the integration test should verify that */* accept header works as well (which it does in manual testing, but yeah).

@whikloj
Copy link
Collaborator Author

whikloj commented Mar 12, 2022 via email

@whikloj whikloj dismissed stale reviews from bbpennel and dbernstein via f8d4099 March 14, 2022 18:57
@bbpennel
Copy link
Collaborator

bbpennel commented Mar 14, 2022

For RDF sources, should we verify that Accept: */* works as well?

@whikloj
Copy link
Collaborator Author

whikloj commented Mar 15, 2022

Sorry about that, I read the need for testing */* and then I focused on Head versus Get in the RDF realm. I hope these changes cover everything.

Copy link
Collaborator

@bbpennel bbpennel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@bbpennel bbpennel merged commit 64db165 into fcrepo:main Mar 15, 2022
@whikloj whikloj deleted the FCREPO-3810 branch July 28, 2022 19:37
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.

None yet

3 participants