Author Topic: Sending a message takes adjacent parameters  (Read 842 times)

Troy

  • Newbie
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
Sending a message takes adjacent parameters
« on: November 24, 2017, 09:11:29 PM »
using (var http = new Http())
                    {
                        http.SocksHostname = hostname" ;
                        http.SocksPort = Port ;
                        http.SocksVersion = 5 ;
                        http.SocksUsername = username ;
                        http.SocksPassword = password ;

                        http.SendCookies = true ;
                        http.SaveCookies = true ;
                        http.CookieDir = "memory" ;
  HttpResponse resp ;
                        using (var req = new HttpRequest())
                        {

                          req.HttpVerb = "GET" ;
                          req.ContentType = "application/x-www-form-urlencoded";
                          req.AddParam("name", name)
                          resp = http.PostUrlEncoded("site.com/signup/",  req) ;

                          req.HttpVerb = "POST" ;
                          req.AddParam("email", email) ;

                          resp = http.PostUrlEncoded("site.com/signup/", req);

                       if (resp.BodyStr.Contains("captcha"))
                         {
                                req.HttpVerb = "GET";
                                var captcha = Pars(resp.BodyStr, "type=(.*?)\\\\");
                                resp = http.PostUrlEncoded("site.ru/captcha?type=" +captcha, req) ;
                                  /*---------------------------------------------*/
                                In the end, I get a request -   site.ru/captcha?type=captcha&email=email
                                When should I receive  -      site.ru/captcha?type=captcha
                                Why are not parameters evaluated after every request?
« Last Edit: November 24, 2017, 09:16:54 PM by Troy »

Chilkat

  • Administrator
  • Full Member
  • *****
  • Posts: 103
  • Karma: +7/-0
    • View Profile
Re: Sending a message takes adjacent parameters
« Reply #1 on: November 29, 2017, 08:57:44 AM »
Use a new instance of the HttpRequest object for the 2nd call to PostUrlEncoded.

Alternatively, remove the "name" query parameter you previously added by calling req.RemoveParam("name").

Note: The request object contains whatever you added to it (such as query parameters, additional request headers, etc.)
The contents of a request object instance aren't going to magically change just because the object is passed to one Http method call and then another..