locked
HttpOpenRequestW RRS feed

  • Question

  • Hello all,

    I've some problem related to HttpOpenRequestW function.
    My solution breaks when I try to get data from the server.

    My code:

    http.WebRequestToFile(L"yandex.ru",L"/yandsearch?text=Sankt-Peterburg&lr=2", NULL);

    //==============

    std::string HTTP::WebRequestToFile(LPCTSTR szUrlDomen, LPCTSTR szUrl, LPCTSTR szFileName){
    hInet = InternetOpen(TEXT("Wininet Test. Windows CE x.x"), INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
    if (hInet){
    HINTERNET hConnection = InternetConnect(hInet, szUrlDomen, INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP,0,1u);

    if (hConnection){
    HINTERNET hRequest = HttpOpenRequestW(hConnection, TEXT("GET"), szUrl, NULL, NULL, 0, INTERNET_FLAG_KEEP_CONNECTION | INTERNET_FLAG_NO_CACHE_WRITE | INTERNET_FLAG_NO_AUTO_REDIRECT | INTERNET_FLAG_NO_COOKIES , 0);

    if (hRequest){
    BOOL bSend = HttpSendRequestW(hRequest, NULL, 0, NULL, 0);
    if (bSend){
    //CString str;

    DWORD dwBytesRead;
    if (szFileName==NULL)
    {

    //Reading first of IBUFFER_LENGHT bytes
    BOOL bRead = InternetReadFile(hRequest, szBuffer, IBUFFER_LENGHT-1, &dwBytesRead);
    I cannot understand where my code has error, because my function works fine with other "get" requests...
    Or maybe I need to use headers...

    TIA
    Sunday, January 31, 2010 11:24 AM

Answers