Forum » Programiranje » Wininet problem
Wininet problem
*ziga* ::
Mogoce kdo ve kaj je pri tej kodi narobe? Imam cca 10 requestov in ce je 1 request SSL potem program na nekaterih racunalnikih crashne(na mojih + vmware dela ok)
char Buffer[1024]; DWORD dwRead; string data; string Request(string method, string host, string file, string headers, string post, bool debug, bool SSL){ HINTERNET hSession, hDownload, hRequest; DWORD flag; DWORD port; data.empty(); //SSL or not + flag :) if(SSL){ port = INTERNET_DEFAULT_HTTPS_PORT; flag = INTERNET_FLAG_SECURE; // FLAG_SECURE } else { port = INTERNET_DEFAULT_HTTP_PORT; flag = INTERNET_FLAG_RELOAD; //FLAG_RELOAD } char * postdata; postdata = new char [post.size()+1]; strcpy (postdata, post.c_str()); char * headersdata; headersdata = new char [headers.size()+1]; strcpy (headersdata, headers.c_str()); //Actual request hSession = InternetOpen("Mozilla/5.0 (Windows; U; Windows NT 6.1; sl; rv:1.9.2.11) Gecko/20101012 Firefox/3.6.11", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0); if(hSession){ hDownload = InternetConnect(hSession, host.c_str(), port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0); if(hDownload){ hRequest = HttpOpenRequest(hDownload, method.c_str(), file.c_str(), "HTTP/1.1", NULL, NULL, flag, 0); if(hRequest){ if(strlen(headersdata) && strlen(postdata)){ HttpSendRequest(hRequest, headersdata, strlen(headersdata), postdata, strlen(postdata)); } else { HttpSendRequest(hRequest, NULL, 0, NULL, 0); } } } } //Writing HTML response in data buffer while(InternetReadFile(hRequest, Buffer, sizeof(Buffer), &dwRead)) { if (dwRead == 0) { break; } Buffer[dwRead] = 0; data += Buffer; } //Debug :) if(debug){ ofstream dbgfile; dbgfile.open ("debug.html"); dbgfile << data; dbgfile.close(); } //Close handles InternetCloseHandle(hSession); InternetCloseHandle(hDownload); InternetCloseHandle(hRequest); return data; }
Vredno ogleda ...
Tema | Ogledi | Zadnje sporočilo | |
---|---|---|---|
Tema | Ogledi | Zadnje sporočilo | |
» | Davčne blagajne (strani: 1 2 3 4 … 24 25 26 27 )Oddelek: Programiranje | 332564 (72567) | Macketina |
» | [JAVA] HTTPS clientOddelek: Programiranje | 3176 (1906) | peterv6i |
» | [C++] charset-aOddelek: Programiranje | 898 (755) | SasoS |
» | [baze] Povezava do slike ali BLOB?Oddelek: Programiranje | 1658 (1455) | BlueRunner |
» | [C#] Prosim pomagajte! Potrebujem program, ki bi pobiral podatke iz ene straniOddelek: Programiranje | 2746 (2356) | David1994 |