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

Side effect when using match stub body with content type is not JSON #9

Open
luat-truong-ts opened this issue Jul 11, 2024 · 1 comment

Comments

@luat-truong-ts
Copy link

Expected Behavior

Using stub using proxy and matching body with content type:

  • Multipart form data
  • Form data
    Expect proxy success

Actual Behavior

Observe the error http: ContentLength=32 with Body length 0

Steps to Reproduce the Problem

Using stub using proxy and matching body with content type:

  • Multipart form data
  • Form data

Potential root cause

SincematchJSONBody using readRequestBody function which return a new reader, matchMultiplePart and matchURLEncodedBody use ParseMultipartForm of HTTP package directly -> This lead to original request body is read once.

Suggest solution

  • Transform request.Body to some struct implement the interface io.Seeker and call Seek(0,0) to reset the reader for each time call to matchBody

Specifications

Version: newest release (1.2.4)

@luat-truong-ts
Copy link
Author

Hi @hungdv136 , Could you please take a look on this issue

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

No branches or pull requests

1 participant