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

[BUGFIX]: fix nil pointer bug in request.Clone() #2

Merged
merged 2 commits into from
Oct 8, 2020

Conversation

romanwozniak
Copy link
Contributor

Problem:

http/request.go relies on .GetBody() function to fetch request payload when fiberhttp.Request is being cloned. .GetBody() function is expected to != nil, because it is always set in the factory method (

req.GetBody = func() (io.ReadCloser, error) { return http.NoBody, nil }
)
However, the .Clone() method doesn't set it and that causes panic in runtime when there is an attempt of cloning previously cloned request.

Solution:

  • set GetBody function on the cloned request
  • update test case to capture the scenario, when the Clone() method is called on the previously cloned request

@romanwozniak romanwozniak added the bug Something isn't working label Oct 7, 2020
Copy link
Contributor

@krithika369 krithika369 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@romanwozniak romanwozniak merged commit 4f0f828 into main Oct 8, 2020
@romanwozniak romanwozniak deleted the NOJIRA_bug_clone_request branch October 8, 2020 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants