Initial
This commit is contained in:
87
wininet/scraps.txt
Normal file
87
wininet/scraps.txt
Normal file
@@ -0,0 +1,87 @@
|
||||
bool HTTPConnection::get(const String &action,HTTPHeader &httpHeader,HTTPData &httpData)
|
||||
{
|
||||
DWORD dwSize(0);
|
||||
String strHeaders;
|
||||
// String strHeader;
|
||||
bool sendResult=false;
|
||||
|
||||
LPSTR accessTypes[2]={"*/*",0};
|
||||
if(!isOkay())return false;
|
||||
mhRequest=::HttpOpenRequest(getHANDLE(),"GET",action.str(),HTTP_VERSION,0,(const char**)&accessTypes,INTERNET_FLAG_RELOAD|INTERNET_FLAG_NO_CACHE_WRITE,0);
|
||||
if(!mhRequest)return false;
|
||||
// strHeader=httpHeader.serialize();
|
||||
if(!::HttpSendRequest(mhRequest,0,0,0,0))return false;
|
||||
// if(httpData.size()&&!strHeader.isNull())sendResult=::HttpSendRequest(mhRequest,strHeader.str(),strHeader.length(),&httpData[0],httpData.size());
|
||||
// else sendResult=::HttpSendRequest(mhRequest,0,0,0,0);
|
||||
// if(!sendResult)return false;
|
||||
::HttpQueryInfo(mhRequest,HTTP_QUERY_RAW_HEADERS_CRLF,0,&dwSize,0);
|
||||
if(!dwSize)return false;
|
||||
strHeaders.reserve(dwSize+1);
|
||||
::HttpQueryInfo(mhRequest,HTTP_QUERY_RAW_HEADERS_CRLF,strHeaders,&dwSize,0);
|
||||
httpHeader=strHeaders;
|
||||
if(httpHeader.isErrorResponse())return false;
|
||||
httpData.size(httpHeader.getContentLength());
|
||||
if(!httpData.size())httpData.size(32768);
|
||||
::InternetReadFile(mhRequest,&httpData[0],httpData.size(),&dwSize);
|
||||
if(dwSize<httpData.size())
|
||||
{
|
||||
HTTPData tmpData;
|
||||
tmpData.size(dwSize);
|
||||
for(int index=0;index<dwSize;index++)tmpData[index]=httpData[index];
|
||||
httpData=tmpData;
|
||||
}
|
||||
closeRequest();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
int main(int argc,char **argv)
|
||||
{
|
||||
Internet internet;
|
||||
HTTPConnection http;
|
||||
HTTPHeader httpHeader;
|
||||
HTTPData httpData;
|
||||
String strApplicationExtension;
|
||||
|
||||
|
||||
::OutputDebugString(Internet::getProxyServer()+String("\n"));
|
||||
if(!internet.open())return 0;
|
||||
|
||||
if(!http.connect(internet,"localhost"))return 0;
|
||||
// httpData="?mailid=10237";
|
||||
// http.get("mailclient/servlet/ReadMailServlet?mailid=10237",httpHeader,httpData);
|
||||
// http.get("diveplanner/aladinv1.00.zip",httpHeader,httpData);
|
||||
http.get("album/diving/divecayman/Cayman10_l.jpg",httpHeader,httpData);
|
||||
|
||||
strApplicationExtension=httpHeader.getApplicationExtension();
|
||||
// File outFile(String("c:\\mail")+strApplicationExtension,"wb");
|
||||
File outFile(String("c:\\mail.jpg"),"wb");
|
||||
|
||||
outFile.write(&httpData[0],httpData.size());
|
||||
outFile.close();
|
||||
::OutputDebugString("Connected.");
|
||||
return 1;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
// File outFile("c:\\mail.txt","wb");
|
||||
// outFile.write(&httpData[0],httpData.size());
|
||||
// http.post("mailclient/servlet/ReadMailServlet",formHeader,httpData);
|
||||
// formHeader.setContentType("application/x-www-form-urlencoded");
|
||||
// httpData="?mailid=10237";
|
||||
// http.post("mailclient/servlet/ReadMailServlet",formHeader,httpData);
|
||||
// ::OutputDebugString(httpData);
|
||||
|
||||
|
||||
// if(!http.getPage("//album//index.html",httpHeader,pageData))return 0;
|
||||
// if(!http.get("//engineer//engineer.zip",httpHeader,httpData))return 0;
|
||||
// File outFile("c:\\engineer.zip","wb");
|
||||
// outFile.write(&httpData[0],httpData.size());
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user