-
Notifications
You must be signed in to change notification settings - Fork 36
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
replace {httr} with {curl} #249
Conversation
…into switch-to-curl
, "1" = .process_legacy_alias | ||
, "2" = .process_legacy_alias | ||
, "5" = .process_new_alias | ||
, "6" = .process_new_alias | ||
, .process_new_alias |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turns out we didn't need any of this stuff!!!
I realized through this exercise that the difference across Elasticsearch versions was like this:
- we weren't passing the
Accept
header in this request toGET /_cat/aliases
- on ES 1.x and 2.x,
GET /_cat/aliases
responded with fixed-width text by default - from ES 3.x onwards, it responded with JSON data by default
- across ALL versions, it responds with JSON data if you pass
Accept: application/json
So just passing that header, this now always returns JSON and no more need for these different processing functions 😁 😁 😁
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
, "1" = .process_legacy_alias | ||
, "2" = .process_legacy_alias | ||
, "5" = .process_new_alias | ||
, "6" = .process_new_alias | ||
, .process_new_alias |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing!
# set headers | ||
# | ||
# This can safely be hard-coded here because every payload this library | ||
# posts and every response body it receives is JSON data. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool!
response <- .request( | ||
verb = "GET" | ||
, url = "https://httpbin.org/status/502" | ||
, body = NULL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forget, does one of the other integration tests use a body? If not maybe we should add one just for a lil more coverage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many do use it implicitly... for example es_search()
is going to issue a POST
request with the query attached as a body.
But agree it'd be good to have an explicit one here, to cover that if()
block. I'll add that before merging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just pushed 51ee836 with 2 more tests, explicitly covering the case where requests have a body.
Those new tests are passing, Thanks as always @austin3dickey |
fixes #229
{httr}
with{curl}
Notes for Reviewers
How I tested this
The existing integration tests cover all the Elasticsearch interactions.
To check that the retry logic works, I built the package from source and installed it.
Then, in R:
Saw logs like this:
And a response object returned: