Constructing http post url parameters (from Forum Nokia wiki)

Source: Internet
Author: User

 

This article shows how to send parameters along with the URL in an http post.

Consider that a Web server needs some parameters for e.g.

 
// Url for post request.
_ Lit8 (kposturi, "http://mysite.net/test/update ");

The following parameters need to be posted to the above URL, username/password

 
_ Lit8 (kpostparamname1, "username ");
_ Lit8 (kpostparamname2, "password ");

This can be done using the HTTP client with form encoder using class chttpformencoder

 
// Construction
Iformencoder = chttpformencoder: newl ();

In the POST request:

Void chttpexampleengine: postrequestl (const tdesc & ausername, const tdesc & apassword)
{
Tbuf8 <50> itemp;
Tbuf8 <50> itemp2;
 
Itemp. Copy (ausername );
Itemp2.copy (kpostparamname1 );
Iformencoder-> addfieldl (itemp2, itemp );
 
Itemp. Copy (apassword );
Itemp2.copy (kpostparamname2 );
Iformencoder-> addfieldl (itemp2, itemp );
 
....
....
 
Itransaction. Request (). setbody (* iformencoder );
Itransaction. submitl ();
}

Remember the following:

 _ lit8 (kuseragent, "httpexample (1.0 )"); // name of this client app 
_ lit8 (kaccept, "text/*"); // accept any (but only) text content
_ lit8 (kpostparamname1, "username"); // name of the parameter in a POST request
_ lit8 (kpostparamname2, "password");
_ lit8 (kpostcontenttype, "text/*"); // content type sent in a POST request
_ lit8 (kcontenttypeform, "application/X-WWW-form-urlencoded/0 ");

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.