gorequest icon indicating copy to clipboard operation
gorequest copied to clipboard

can't set http header or send request body

Open zhqqqy opened this issue 4 years ago • 1 comments

If I do the following then the query body can't send successful.

   request := gorequest.New()
   request.Post("http://address").
       Send(`{"query":{"match_phrase":{"age":"327"}}}`).
       Set("Content-Type", "application/x-www-form-urlencoded").End()

but if I do the following then the http header can't set successful.

    request := gorequest.New()
    request.Set("Content-Type", "application/x-www-form-urlencoded").
        Post("http://address").
        Send(`{"query":{"match_phrase":{"age":"327"}}}`).End()

zhqqqy avatar Feb 04 '21 12:02 zhqqqy

See https://github.com/parnurzeal/gorequest/issues/76 you should call request.Post first or set flag SetDoNotClearSuperAgent

lethe3000 avatar Apr 07 '21 10:04 lethe3000