title: Hep on HttpOpenRequest() and other Wininet functions
body: <p>I'm still at it with saving random webpages from the web. After a slight modification to the code (calling HttpOpenRequest() differently), the program successfully downloaded a page that was being redirected. But I still can't get whatever webpage I want.</p>
  
  <p>Example:</p>
  
  <pre><code>#include &lt;windows.h&gt;
  #include &lt;wininet.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;fstream&gt;
  #include &lt;cstring&gt;
  
  #define SIZE 128
  
  
  int main()
  
  {
  
      HINTERNET Initialize,Connection,File;
      DWORD dwBytes;
  
      char ch;
      Initialize = InternetOpen("HTTPGET",INTERNET_OPEN_TYPE_DIRECT,NULL,NULL,0);
  
      Connection = InternetConnect(Initialize,"http://www.rottentomatoes.com",INTERNET_DEFAULT_HTTP_PORT,
      NULL,NULL,INTERNET_SERVICE_HTTP,0,0);
  
  
      //File = HttpOpenRequest(Connection,NULL,"/index.html",NULL,NULL,NULL,0,0);
  
  /**/
  
      File = HttpOpenRequest(Connection,
                                  "GET",
                                  "/index.jsp",
                                  "HTTP/1.1",
                                  NULL, NULL,
                                  INTERNET_FLAG_RELOAD | INTERNET_FLAG_EXISTING_CONNECT, 0);
  
      if(HttpSendRequest(File,NULL,0,NULL,0))
      {
          std::ofstream webSource;
          //webSource.open(strcat(argv[1], "__.html"));
          webSource.open("a.html");
  
          while(InternetReadFile(File,&amp;ch,1,&amp;dwBytes))
          {
              if(dwBytes != 1)break;
              webSource &lt;&lt; ch;
          }
          webSource.close();
      }
  
      InternetCloseHandle(File);
      InternetCloseHandle(Connection);
      InternetCloseHandle(Initialize);
  
      return 0;
  }
  </code></pre>
  
  <p>But when I try to download "http://www.rottentomatoes.com/m/1209933-puss_in_boots/", I fail, that is, the program runs for less than a second and produces no output file.</p>
  
  <p>What's the problem here, what function is causing this to happen?</p>