-
Notifications
You must be signed in to change notification settings - Fork 84
Description
I'm writing an API wrapper that POSTs a command to the server via req_stream to select which data to return. If the posted body is malformed, the server responds with error code 400 causing the open command within req_stream to throw an error. The error prevents the subsequent reading of the error contents by the callback and prevents the subsequent creation of a new_response return value containing the status code.
The R curl_fetch_stream function does not suffer this same limitation because it opens the stream using "rbf" mode instead of "rb" mode. According to the curl's internal code comment, "# 'f' means: do not error for status code".
I request that req_stream be modified such that
stream <- curl::curl(req$url, handle = handle)
open(stream, "rb")
becomes
stream <- curl::curl(req$url, handle = handle)
open(stream, "rbf")
My local testing shows that this change prevents R from throwing an error, allows subsequent parsing of the stream contents, and correctly creates the new_response code with the observed status code.