Skip to content
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

Add a failing spec demonstrating a bug in the em-http-request adapter. #185

Merged
merged 3 commits into from
Aug 26, 2012

Conversation

myronmarston
Copy link
Collaborator

When a request is made to a URL that returns a 3xx response and the
:redirects option is set, the globally_stub_request/after_request
hooks are not paired properly. Both hooks should receive the original
request and the redirect-following request.

This spec should probably be re-written to use the local webmock
server, but I couldn't figure out how to get it to conditionally
send a redirect response since it writes directly to the socket
and doesn't (as far as I can tell) have the request info available
in that scope...so there's not easy way to have it send a different
response for different requests :(.

See myronmarston/vcr#171 for the original VCR issue that caused
me to investigate this bug.

@bblimke -- let me know if I can help with this in anyway. I'm pretty useless when it comes to em-http issues since I've never used it but I'll see what I can do. Also, there's some other weirdness here...the spec for the after_request hook fails in different ways, different times it is run...sometimes the after_request hook is invoked twice and sometimes it's invoked only once. Either way, it never gets invoked with the https redirect URL.

When a request is made to a URL that returns a 3xx response and the
:redirects option is set, the globally_stub_request/after_request
hooks are not paired properly.  Both hooks should receive the original
request and the redirect-following request.

This spec should probably be re-written to use the local webmock
server, but I couldn't figure out how to get it to conditionally
send a redirect response since it writes directly to the socket
and doesn't (as far as I can tell) have the request info available
in that scope...so there's not easy way to have it send a different
response for different requests :(.

See myronmarston/vcr#171 for the original VCR issue that caused
me to investigate this bug.
@bblimke
Copy link
Owner

bblimke commented May 28, 2012

Hi Myron,

Thanks for the test. I don't have much time now, but I'll try to fix it at some point.

@myronmarston
Copy link
Collaborator Author

@bblimke -- thanks for all your work on WebMock. It'd be nice to get this fixed at some point but it's not a blocker for VCR or anything like that.

@markiz -- As a VCR/WebMock/em-http-request user (and the source of the original bug report on the VCR issue tracker), it'd be great if you could jump in here and try to fix this yourself, if you have the time.

@markiz
Copy link
Contributor

markiz commented May 30, 2012

Understood. I will try sometime around the weekend then.

…ns a 3xx response and the :redirects option is set, the globally_stub_request/after_request

hooks are now fired for the original request and the redirect-following request.
@bblimke bblimke merged commit 806818f into master Aug 26, 2012
@bblimke
Copy link
Owner

bblimke commented Aug 26, 2012

@myronmarston ok, it should work fine now, but I'm not sure it's now compatible with the workaround you did in VCR. Please test and let me know.

@myronmarston
Copy link
Collaborator Author

VCR's specs are all green. Thanks for fixing this!

@jarthod
Copy link

jarthod commented Dec 15, 2012

Mmm I have a similar issue:

A request stubbed as 302 by webmock doesn't get followed by em-http-request despite the :redirect parameter.
My test works fine with real HTTP connection (http://www.google.com (302) => http://www.google.fr (200))

But if I try to stub the two requests, after the first is done (the 302) em-http-request calls the headers AND callback callbacks in a row with the same headers (the first response) and without doing the second request.

I'm using webmock 1.9.0 and em-http-request 1.0.3.
I'll try to write a simplified test demonstrating this.

@jarthod
Copy link

jarthod commented Dec 15, 2012

I wrote a small test to reproduce the issue, here it is: https://gist.github.com/4294952
I would like to help fix this, i'll try to have a look at the source but this is a bit obscure to me ;)

@bblimke
Copy link
Owner

bblimke commented Dec 28, 2012

@jarthod WebMock doesn't currently follow redirects returned from stubbed responses in none of the supported http clients. I suggest opening a new issue for that as this is a different issue.

@jarthod
Copy link

jarthod commented Dec 29, 2012

Ok, I openned a new issue: #237

@davidbegin davidbegin deleted the vcr-171 branch May 10, 2015 02:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants