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

Restore Original URL of the context after changing it #1788

merged 3 commits into from Feb 20, 2022


Copy link

@geet geet commented Feb 20, 2022

Please provide enough information so that others can review your pull request:
This PR fixes two issues.

  1. Restore original URL after proxy.Do issue
    The proxy.Do method changes the c.OriginalURL() while setting the requestURI req.SetRequestURI(addr)
    Since proxy.Do can be used inside the fiber handlers, it will change the origialURL() since the reference to the context is passed. To fix this behaviour, I am resetting it once the proxy is done.

  2. The similar issue was raised for sendFile and a fix was merged. However. I find that the fix is not working.

Explain the details for making this change. What existing problem does the pull request solve?

Because of the current behaviour, if we use c.OriginalURL() after invoking the proxy.Do() or sendFile() it will cause side effects as c.OriginalURL() will continue to point to the url changed in the proxy.Do() or sendFile() method.

Note: using ImmutableString for persisting strings has a slight performance cost. Mentioned in the welcome page of fiber under Zero allocation
(This is my first PR in this project. Please let me know if I need to make some changes)

Copy link

welcome bot commented Feb 20, 2022

Thanks for opening this pull request! 🎉 Please check out our contributing guidelines. If you need help or want to chat with us, join us on Discord

Copy link

@efectn efectn left a comment

You should use CopyString instead of ImmutableString due to it's deprecated.

Copy link
Contributor Author

geet commented Feb 20, 2022


@efectn Thanks for the suggestion. CopyString is better approach. Changing ImmutableString to CopyString

@geet geet requested a review from efectn Feb 20, 2022
efectn approved these changes Feb 20, 2022
Copy link

@efectn efectn left a comment

Looks good to me.

@ReneWerner87 ReneWerner87 merged commit a746e5b into gofiber:master Feb 20, 2022
14 checks passed
Copy link

welcome bot commented Feb 20, 2022

Congrats on merging your first pull request! 🎉 We here at Fiber are proud of you! If you need help or want to chat with us, join us on Discord

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

Successfully merging this pull request may close these issues.

4 participants