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

Issue on MakeRequest() method with calling Type("multipart") before #204

Open
Tracked by #16 ...
nisiyu opened this issue Aug 21, 2018 · 0 comments · May be fixed by #216
Open
Tracked by #16 ...

Issue on MakeRequest() method with calling Type("multipart") before #204

nisiyu opened this issue Aug 21, 2018 · 0 comments · May be fixed by #216

Comments

@nisiyu
Copy link

nisiyu commented Aug 21, 2018

I'm now using gorequest lib to do some httptest in my code, and I found a problem that when I want to use makerequest with a Type method called before, It will always make a request with application/json content-type header, like the code below.

  goreqObj := gorequest.New()
  goreqObj.
   Post("/v1/api/company/employees").
   Type("multipart").
   Set("Authorization", "Bearer "+authToken).
   Send(body)
  req, _ := goreqObj.MakeRequest()
  w := httptest.NewRecorder()
  r.ServeHTTP(w, req)

Then I check the source code in gorequest lib, I found that Type() method assigns multipart in a field of "ForceType" in the SuperAgent. But only "TargetType" is regarded in the MakeRequest() method. Only when use EndByte() method, the ForceType is assigned to the TargetType

For this case, I insert the code before MakeRequest() to solve this problem.

  goreqObj.TargetType = goreqObj.ForceType

I'm wondering if it is a bug.

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

Successfully merging a pull request may close this issue.

1 participant