…so that correct error is thrown. This is common with conditional requests where a 304 error is returned with an empty body to indicate that the resource hasn't been modified.
Currently, gh fails to return the correct error from gh_error() when res is raw(0) (an empty response body).
This PR checks if length(res) == 0 and if so initializes res = list(message = "Empty Body").
# With the change from this PR...
gh(issue, .send_headers = c("If-Modified-Since" = last_modified))
#> Error in gh_process_response(raw):
#> GitHub API error (304): 304 Not Modified
#> Message: Empty Body
I tried to create a test based on the above reprex, but couldn't quickly figure out how to setup httrmock. Hopefully the above reprex is a good start.
…so that correct error is thrown. This is common with conditional requests where a 304 error is returned with an empty body to indicate that the resource hasn't been modified.
Currently,
gh
fails to return the correct error fromgh_error()
whenres
israw(0)
(an empty response body).This PR checks if
length(res) == 0
and if so initializesres = list(message = "Empty Body")
.I tried to create a test based on the above reprex, but couldn't quickly figure out how to setup httrmock. Hopefully the above reprex is a good start.