How do I have to send a form to an HTTP server, using a "post" method ?
I tried
CInternetSession * ISp_session;
CHttpFile * HFp_file;
CHttpConnection * HCp_conn;
CStrin S_req;
ISp_session = new CInternetSession;
HCp_conn = ISp_session -> GetHttpConnection ("http://..."); // "action"
in the form
HFp_file = HCp_conn -> OpenRequest (CHttpConnection::HTTP_VERB_POST,
"verb");
S_req = "data=value";
HFp_file -> SendRequest (S_req);
I always get a strange exception, not catched up by CInternetException.
Apparently some argument problem.
Any clue ?
>ISp_session = new CInternetSession;
>HCp_conn = ISp_session -> GetHttpConnection ("http://..."); // "action"
in the form
according to docs, GetHttpConnection requires the servername only, not an
URL.
e.g. "myserver" or "10.11.12.13"
>HFp_file = HCp_conn -> OpenRequest (CHttpConnection::HTTP_VERB_POST,
"verb");
instead of "verb" --> here goes the file part, e.g.
"/myweb/scripts/handler.exe" or "myweb/hanlder.asp"
> S_req = "data=value";
> HFp_file -> SendRequest (S_req);
I am not a real expert on this, but there is one clear problem here: you are
trying to send "data=value" as request header, not as data stream (which is
required by POST).
Maybe you should attempt something like
HFp_file->Write("data=value",10);
HFp_file->SendRequest();
Let me admit I have no real experience doing this in C++, but anyway these
remarks should get you going.
Good luck
Andreas
I have installed the Certificate for SSL on my IIS4.0 server and tried to
view the ASP-pages from my Netscape Navigator/Internet Explorer without
any problem.
When I run my application I get the exception:
"Certification organization invalid" (my translation from swedish)
from the "SendRequest()" function below.
The code works fine if I am not using SSL and remove the flag:
INTERNET_FLAG_SECURE.
Can somebody help me with this? The code follows below.
Regards
Rikard Ambric (amb...@algonet.se)
Code:
DWORD dwAccessType = PRE_CONFIG_INTERNET_ACCESS;
DWORD dwHttpRequestFlags =
INTERNET_FLAG_EXISTING_CONNECT |
INTERNET_FLAG_NO_AUTO_REDIRECT |
INTERNET_FLAG_SECURE;
CHttpConnection* pServer = NULL;
CHttpFile* pFile = NULL;
LPCTSTR pszAppName = _T("appl");
string strURL = "https://www.site.se/appl/page.asp";
CString strServerName;
CString strObject;
INTERNET_PORT nPort;
DWORD dwServiceType;
AfxParseURL(strURL.c_str(), dwServiceType, strServerName, strObject, nPort)
CInternetSession session(pszAppName, 1, dwAccessType);
pServer = session.GetHttpConnection(strServerName, nPort);
pFile = pServer->OpenRequest(CHttpConnection::HTTP_VERB_GET,
strObject, NULL, 1, NULL, NULL, dwHttpRequestFlags);
pFile->AddRequestHeaders(headers);
pFile->SendRequest();
.
.
.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own