title: 400.0 - Bad Request with MSXML2::IXMLHTTPRequestPtr
body: <p>I'm trying to access an xml file over http. The address is similar to:</p>
  
  <pre><code>http://localhost/app/config/file.xml
  </code></pre>
  
  <p>When pasting this in a browser the xml is displayed as expected. In my software I am using:</p>
  
  <pre><code>MSXML2::IXMLHTTPRequestPtr rp;
  ...
  rp-&gt;open( "GET" , "http://localhost/app/config/file.xml" );
  </code></pre>
  
  <p>and getting the following response:</p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"     
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt; 
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; 
  &lt;head&gt; 
  &lt;title&gt;IIS 7.0 Detailed Error - 400.0 - Bad Request&lt;/title&gt; 
  &lt;style type="text/css"&gt; 
  &lt;!
  </code></pre>
  
  <p>Does anyone have any ideas what might be happening?</p>
  
  <p>EDIT: more info, when trying to connect to another server in the office (which I can connect to fine using a browser) I'm getting a response of "Bad Request" and no more. </p>
  
  <p>The function making the call is:</p>
  
  <pre><code>#import "msxml3.dll"
  
  BOOL HTTPGet(LPCTSTR URL, CString &amp;Response, long Timeout, BOOL ForceNoCache )
  {
  BOOL ret = FALSE;
  
  MSXML2::IXMLHTTPRequestPtr rp;
  //MSXML2::IServerXMLHTTPRequestPtr rp;
  
  try
  {
      HRESULT hr = rp.CreateInstance( __uuidof( MSXML2::XMLHTTP ) );
      //HRESULT hr = rp.CreateInstance( __uuidof( MSXML2::ServerXMLHTTP30 ) );
  
      if( SUCCEEDED( hr ) )
      {
          rp-&gt;open( "GET" , URL );
          if( ForceNoCache )
              rp-&gt;setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 1970 00:00:00 GMT" );
          rp-&gt;send();
  
          for( DWORD tc = GetTickCount() ; rp-&gt;readyState != 4 &amp;&amp; GetTickCount() &lt; tc + Timeout ; )
          {
              Sleep( 50 );
              //WaitMessage();
              for( MSG msg ; PeekMessage( &amp;msg, 0, 0, 0, PM_REMOVE ) ; )
              {
                  TranslateMessage( &amp;msg );
                  DispatchMessage( &amp;msg );
              }
  
          }
  
          if( rp-&gt;readyState == 4 )
          {
              Response = (LPCSTR)rp-&gt;responseText;
              ret = TRUE;
          }
          else
              Response = "Timed out";
      }
  }
  catch( CException &amp;e )
  {
      char err[ 2048 ];
      if( e.GetErrorMessage( err , sizeof( err ) ) )
          Response = err;
      else
          Response = "Unhandled exception";
  }
  catch( _com_error &amp;e )
  {
      Response = e.ErrorMessage();
  }
  catch( ... )
  {
      Response = "Unhandled exception";
  }
  
  return ret;
  }
  </code></pre>
  
  <p>EDIT2:
  The function works correctly when ForceNocache set to false making the If-Modified-Since header the problem... I'll start up a new question if I can't work out why this isn't liked (by iis 7) but if someone here can point me in the right direction it will save some noise.</p>
  
  <p>Thanks for all your help.</p>