The difference between the POST mode and the GET is to separate the transmitted data and web page addresses. Place the data in the HTTP protocol's head section, so there is a strunters = _t ("Content-Type: Application / X-WWWW-FORM-URLENCODED" in the program, you can also change according to your needs, such as change For images, or binary files, etc. In the following source program, I use blue to marke with the previous page "GET mode"; where StrformData is the format to send, the content is "
CURL = Chinese & http = http://www.chinaren.comcuurl= Squirrel House & http = http://www.fadshop.net/squirrel/ &curl= New Sword & http = http://www.xys.org
"Of course, you need to organize the content here according to your needs.
#ifndef _debug
Strhttpname = "http://www.fadshop.net/curl/progsave.asp";
#ELSE
StrHttpname = "http://mycomputer/fadshop/curl/progsave.asp";
#ENDIF
// strHttpname = strHTTPNAME "?" strformdata;
Use this sentence to send data with GET
CinternetSession sess; // Establish a session
Chttpfile * fileget;
CString strheaders =
_T ("Content-Type: Application / X-WWW-FORM-URLENCODED");
CEXCEPTION * E;
Try
{
Fileget = (chttpfile *) sess.openurl (strHttpname); // Open file
}
Catch_all (e)
{
TRACE ("Err:% D / N", getLastError ());
Fileget = 0;
}
END_CATCH_ALL
IF (Fileget)
{
DWORD DWSTATUS;
DWORD DWBUFFLEN = SizeOf (DWSTATUS);
Bool bsuccess = fileget-> queryinfo (
Http_query_status_code | http_query_flag_number,
& DWSTATUS, & DWBUFFLEN;
StrgetSentence = ""
IF (Bsuccess && DWSTATUS> = 200 && DWSTATUS <300) {
Bool result = fileget-> sendrequest (strheaders,
(LPCTSTSTR) StrformData, StrformData.getlength ());
While (fileget-> readstring (strSentence)) {
strGetSentence = StrgetSentence Strsentence Char (13)
Char (10);
} / / Get the return byte and display setdlgitemtext (IDC_Comment,
StrgetSentence); setdlgitemtext (IDC_UPLOADMSG,
"The upload is complete, the squirrel thank you for your cooperation.");} // if
BSUCCESS.
Else setdlgitemtext (IDC_UPLOADMSG, "uploaded error / n Please execute it next time, or go to Squirrel home to view the latest information."); fileget-> close ();
DELETE Fileget;
}
Else
Setdlgitemtext (IDC_UPLOADMSG, "network is not available, please check your network connection.");
sess.close ();