File tree Expand file tree Collapse file tree 3 files changed +11
-4
lines changed
Expand file tree Collapse file tree 3 files changed +11
-4
lines changed Original file line number Diff line number Diff line change 11# httr2 (development version)
22
3+ * ` last_response_json() ` now works with content-types that end with ` +json ` ,
4+ e.g., ` application/problem+json ` (@cgiachalis , #782 ).
5+
36# httr2 1.2.2
47
58* httr2 will now emit OpenTelemetry traces for all requests when tracing is enabled. Requires the ` otelsdk ` package (@atheriel , #729 ).
Original file line number Diff line number Diff line change @@ -61,9 +61,12 @@ last_response_json <- function(pretty = TRUE) {
6161 if (is.null(resp )) {
6262 cli :: cli_abort(" No request has been made successfully yet." )
6363 }
64- if (! identical(resp_content_type(resp ), " application/json" )) {
65- cli :: cli_abort(" Last response doesn't have a JSON body." )
66- }
64+ check_content_type(
65+ resp_content_type(resp ),
66+ valid_types = " application/json" ,
67+ valid_suffix = " json" ,
68+ inform_check_type = TRUE
69+ )
6770 httr2_json(resp_body_string(resp ), pretty = pretty )
6871}
6972
Original file line number Diff line number Diff line change 3535 last_response_json()
3636 Condition
3737 Error in `last_response_json()`:
38- ! Last response doesn't have a JSON body.
38+ ! Unexpected content type "application/xml".
39+ * Expecting type "application/json" or suffix "json".
3940
4041# useful errors if no last request/response
4142
You can’t perform that action at this time.
0 commit comments