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

Implement request callbacks, closes #408 #409

Merged
merged 2 commits into from Nov 18, 2016

Conversation

Projects
None yet
2 participants
@gaborcsardi
Member

gaborcsardi commented Nov 13, 2016

More details in #408. There is an HTTP mocking implementation that uses this, in the https://github.com/gaborcsardi/httrmock package.

@hadley

Looks good.

However, I do wonder if the interface would be a little cleaner if there were multiple callbacks, rather than calling the same callback with different arguments.

set_callback("request", ...)
set_callback("response", ...)
R/request.R Outdated
@@ -122,6 +122,12 @@ request_prepare <- function(req) {

request_perform <- function(req, handle, refresh = TRUE) {
stopifnot(is.request(req), inherits(handle, "curl_handle"))

orig_req <- req

This comment has been minimized.

@hadley

hadley Nov 13, 2016

Member

Can you this and the block below up into a small helper function that lives in callback.r?

This comment has been minimized.

@gaborcsardi

gaborcsardi Nov 13, 2016

Member

Sure. Btw. I was also thinking that probably we should use the request as it is sent out, i.e. after request_prepare, no?

This comment has been minimized.

@hadley

hadley Nov 14, 2016

Member

Yes, I'd say so.

@gaborcsardi

This comment has been minimized.

Member

gaborcsardi commented Nov 13, 2016

Yes, two callbacks is definitely cleaner, I'll do that, too.

@gaborcsardi gaborcsardi referenced this pull request Nov 16, 2016

Open

Test cases #8

@gaborcsardi gaborcsardi force-pushed the gaborcsardi:callback branch from 3b5fcb5 to 8652fdd Nov 18, 2016

@gaborcsardi

This comment has been minimized.

Member

gaborcsardi commented Nov 18, 2016

@hadley OK, updated, PTAL.

@hadley

This comment has been minimized.

Member

hadley commented Nov 18, 2016

LGTM - can you please add a bullet to NEWS?

@gaborcsardi

This comment has been minimized.

Member

gaborcsardi commented Nov 18, 2016

Added NEWS.

@hadley hadley merged commit 8fa4a71 into r-lib:master Nov 18, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@hadley

This comment has been minimized.

Member

hadley commented Nov 18, 2016

Thanks!

jiwalker-usgs added a commit to jiwalker-usgs/httr that referenced this pull request Jul 24, 2017

Implement request callbacks, closes r-lib#408 (r-lib#409)
* Implement request callbacks, closes r-lib#408

* NEWS about callbacks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment