Allow request/response interception on stubs - #232
Merged
Merged
Conversation
Signed-off-by: Hermann Mayer <[email protected]>
Collaborator
|
Found this issue, but not sure if the workarounds are applicable: websocket-rails/websocket-rails#191 |
Signed-off-by: Hermann Mayer <[email protected]>
Contributor
Author
|
@ronwsmith Thanks for the assistance! I dug into this and found a solution. Hope this is good to merge then? |
Collaborator
|
Looks good, I'll try to get this in next week. |
Collaborator
|
Released in 1.1.0 |
Contributor
|
Hey; I've just upgraded to v1.1.0 and this is a breaking change for our code base. Just cross referencing this issue I've created: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
- What is it good for?
This update ships the possibility to intercept requests and responses on the proxy stub method. This is quite handy when you want to modify ugly client requests or just want to modify the response body on certain requests. In the test suite where this feature was implemented, we wanted to intercept responses with a content disposition header and save their content to file. (aka file download) This is required due to the some bugs on Chrome atm. (Cant save PDF files on headless, crash on new tabs of PDF files on non-headless)
- What I did
I added a new
pass_requestmethod to theProxyRequestStubclass which makes use of the existing functionality of the proxy handler. Furthermore, I switched the proc execution mechanism fromProc#calltoObject#instance_execto allow a lean syntax on the given Proc. See the examples in the readme. I also added the requested URL and its HTTP method to the list of arguments of theand_returncallable. This was proved on the corresponding test. A new test case was added to prove thepass_requestmechanism. Unfortunately eventmachine weeps about:(eval):8:inresume': double resume (FiberError)` on the test case. I have to dig into this, or if anybody knows why/how to fix this - tell me. :)- A picture of a cute animal (not mandatory but encouraged)