Chilkat Forum

Technologies => REST / HTTP / HTTPS => Topic started by: Troy on November 24, 2017, 09:11:29 PM

Title: Sending a message takes adjacent parameters
Post by: Troy 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?
Title: Re: Sending a message takes adjacent parameters
Post by: Chilkat 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..