k6 icon indicating copy to clipboard operation
k6 copied to clipboard

Moving prepareHeaders back to Client.NewRequest

Open cuonglm opened this issue 6 years ago • 0 comments

PR #1240 fixes issue #1239 by moving prepareHeaders inside Client.Do

That fixes the issue, but against original discussion.

There're some problems we can see:

  • Client.NewRequest always serializes data in JSON forma.
  • Above reason causes http.NewRequest must be used to create POST request with form data.

I propose some solutions:

  • Leave prepareHeaders inside Client.Do as I proposed before.
  • Moving prepareHeaders back to NewRequest, introduce new method NewRequestWithForm, which will handle POST form data.
  • Change Client.NewRequest signature to get more parameters, something for it to differentiate between json and form data.

The 3rd point will be backward in-compatible.

cuonglm avatar Nov 13 '19 04:11 cuonglm