Fix last_response_json() to work with 'application/problem+json' #832
Merged
Conversation
Member
|
I'm pretty sure there's some existing suffix parsing code that you could use to determine if there's a |
Contributor
Author
|
Do you want me to replace Lines 64 to 66 in c7d4a86 with resp_check_content_type(
resp,
valid_types = "application/json",
valid_suffix = "json",
check_type = TRUE
)
# or
check_content_type(
resp_content_type(resp),
valid_types = "application/json",
valid_suffix = "json",
inform_check_type = TRUE
)? Example:library(httr2)
req_perform(request(httr2:::example_url("/xml")))
#> <httr2_response>
#> GET http://127.0.0.1:57838/xml
#> Status: 200 OK
#> Content-Type: application/xml
#> Body: In memory (610 bytes)
resp <- last_response()
# last_response_json() will use
httr2:::check_content_type(
resp_content_type(resp),
valid_types = "application/json",
valid_suffix = "json",
inform_check_type = TRUE
)
#> Error:
#> ! Unexpected content type "application/xml".
#> • Expecting type "application/json" or suffix "json".Created on 2026-01-14 with reprex v2.1.1 |
Member
|
Yes, that sounds great |
Member
|
Looks good! Can you please also add a news bullet to the top of |
hadley
reviewed
Jan 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #782
last_response_json() { "type": "https://datatracker.ietf.org/doc/html/rfc9110#section-15.5.1", "title": "Bad Request", "status": 400, "detail": "bad request" }