title: Hosting Mercurial with IIS 6
body: <p>I'm trying to set up Mercurial repositories to be hosted by IIS under Windows Server 2003. Following <a href="https://stackoverflow.com/questions/818571/how-to-setup-mercurial-and-hgwebdir-on-iis">this post</a> I installed Python 2.5.4.4 and Mercurial 1.3, set up virtual dir, extracted library.zip and created hgwebdir.config.</p>
  
  <p>However, when I trying to open the <a href="http://hostname/hg/hgwebdir.cgi" rel="nofollow noreferrer">http://hostname/hg/hgwebdir.cgi</a> I got an error “The specified CGI application misbehaved by not returning a complete set of HTTP headers.” I did all by best:</p>
  
  <ol>
  <li>Checked IIS mappings to both .py and .cgi extensions. I even tried to use FastCGI with no success.</li>
  <li>Created “Hello World” in the same dir and checked that it works fine.</li>
  <li>Checked read/exec permissions to Python, IIS and repos directories for IUSR, IWAM and NETWORK SERVICE.</li>
  <li>Tried to apply two different patches from <a href="http://www.nabble.com/Mercurial-f24354.html" rel="nofollow noreferrer">Mercurial mailing list</a>. Since they both are old I haven't success with it.</li>
  <li>INstalled Sysinternals' procmon and checked for filesystem errors during request. I found nothing except lots of Buffer Overflow results in Python process while it loads it's libraries.</li>
  <li>Tried to add 'Content-type: text/html' to the script.</li>
  </ol>
  
  <p>One more thing is when I'm requesting inexistent script file (e.g /hg/inexist.cgi) I have the same error. Nothing helped!</p>