Question:
Hi Chilkat,
I tried to send a Http POST (without url encoding for the params), but when I looked at the log, the request become a GET instead !
As I understood from the following link, content-type should be set to "text/namevalue".
http://www.example-code.com/vcpp/paypal_creditcardpayment.asp
I tried both
a. Request.put_ContentType("text/namevalue");
b. Request.AddHeader("Content-Type","text/namevalue");
still it doesn't work ie. GET is sent instead of POST.
Latest library is used ie.v9.5.0.50 VC++ 9.0 / win32 (VS2008).
I believe it is a bug.
Fya.
Best regards
Dragon
Check out the documentation of the RedirectVerb property (I think it will help):
RedirectVerb Indicates the HTTP verb, such as GET, POST, PUT, etc. to be used for a redirect when the FollowRedirects property is set to 1. The default value of this property is "GET". This will produce the same behavior as a web browser (such as FireFox). If this property is set to the empty string, then it will cause the same verb as the original HTTP request to be used.
Note: Prior to version 9.5.0.44, the default value of this property was the empty string.
If you explicitly clear the RedirectVerb property, do you get a POST after redirect?
Hi jpbro,
Sorry for my late reply and thanks again for your fast response !
I looked at the log again. My mistake ! I missed out the detail.
Initially, a Correct POST was sent. However, the response received is :
HTTP/1.1 302 Moved Temporarily
Then, the problem appeared, the POST was resend....
It become a GET....
Hence, need to test on a website which will reply "HTTP/1.1 302 Moved Temporarily" to see the issue.
Thanks.
Hi jpbro,
Bingo ! Yes, you are right !
I believe that I have to read the documentation thoroughly next time.
Thanks for your great help !
Best regards Dragon
Hi jpbro,
Ok, done !
Thanks again !
Best regards Dragon
Did you call UsePost on the CkHttpRequest object (though deprecated, I believe it still works), or event better set the HttpVerb property of the CkHttpRequest object to "POST"?
Hi jbro,
Thanks for your fast reply.
Yes, I did.
Request.put_HttpVerb("POST");
Request.put_Path("/login.php");
Request.put_ContentType("text/namevalue");
Request.AddHeader("Accept","application/json, text/javascript, /; q=0.01");
Request.AddHeader("X-Requested-With","XMLHttpRequest");
Request.AddHeader("Accept-Language","zh-CN");
Request.AddHeader("User-Agent","Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko");
Request.AddHeader("Connection","Keep-Alive");
Request.AddHeader("Host",szDomain);
Request.AddHeader("Pragma","no-cache");
Request.AddParam("act","login");
Request.AddParam("tbUserAccount",szUserAccount);
Request.AddParam("tbUserPwd",szUserPwd);
Request.AddParam("tbCode","");