-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Header passing fails with header that starts with HTTP_ #590
Comments
I'm interested in getting this fixed for an API I'm working with (the offending header in my case is Do status codes always start with ty! |
Not sure if of any help. But today I got the exact same warning for another API (Caplena - non-public, so can't share any reprex) that is new, i.e. it never occured before and I didn't change any code. The specifc API request is (where
The problem is, if I now want to turn the response object into something readable, I was able to do so previously with:
This returned a list obbject I could then process further. Now, I have to change this to
Any helpful information I should add here from the response objects (e.g. the headers or sth.)? |
One small update. I tested it a bit further and the warning only occurs on Windows machines, NOT on MACs. My IT suggests that it might indeed be related to this part here:
especially the second line, because there is no carriage return on Windows. Or the order of line break and carraige return is different than on Mac, (I didn't fully understand this part). OK, did some more debugging, and the issue is in Before getting into that function we are in the above function where the results of the lines, new_response and grps is:
And the problem is in the second group. In the
And if we feed it to the
where And then the first line returns a list with two elements, but the So that's what I can contribute and I hope there is something we/you can do about it. FWIW, here's also the content of the
One last update: it seems the initial problem why it (now) doesn't work on Windows, but still works on Mac, is that this second http occurence "HTTP_X_CORRELATION_ID: 44398-1" is uppercase on Windows, but lowercase on Mac. And that's why the function gets confused on Windows because it checks for uppercase HTTP in the |
Investigated a bit further here and first thing is that HTTP headers are case insensitive, so not sure what httr would return if a website uses lowercase (because the grepl in And second thing is that the parsing of the status purely by the header starting with "http" is problematic. Maybe the header should be split and then checked if any element contains a number that would be a valid status response (e.g. a 200 or 404 or sth.). |
httr has been superseded in favour of httr2, so is no longer under active development. If this problem is still important to you in httr2, I'd suggest filing an issue offer there 😄. Thanks for using httr! |
I'm using httr to query some data from the Shopify API. Every call I make generates the warning message "In parse_http_status(lines[[1]]) : NAs introduced by coercion". For example,
It seems that the culprit is this function
specifically this bit:
new_response <- grepl("^HTTP", lines)
that attempts to pick out HTTP status lines from the vector oflines
. Shopify's API always returns a header line like "HTTP_X_SHOPIFY_SHOP_API_CALL_LIMIT: 1/40" and this is falsely getting identified as an HTTP status line. Further down, it's getting parsed and anas.integer(status$status)
bit it causing the coercion warning.Can the regex used to identify HTTP status lines be tightened to prevent this false positive? Apologies - I don't know enough about possible HTTP status formats to make a good suggestion.
Thanks!
The text was updated successfully, but these errors were encountered: