facebook/hhvm — pull request #3941 by jazzdan (2014-10-09 21:40:31+00:00)
Title: Content-Type should only be set once when handling admin server requests

Instead of setting multiple Content-Types, change the Content-Type to what is being returned.

This caused problems when fronting the admin server with Apache. For some commands it was fine (eg check-load) but for commands that returned html, xml or json Apache would return a 500 error and complain about

```
FastCGI: comm with server "/hhvm-admin" aborted: error parsing headers: duplicate header 'Content-Type'
```

After using the fcgi CLI protocol to see what hhvm was sending back I noticed that HHVM would sometimes send back two content types: always text/plain followed by the actual content type, say application/json. After poking through the code I noticed that it seems to do just that: when an admin server request received it would set the Content-Type to text/plain and if the command returned some other content type it would set *another* Content-Type header to the real Content-Type.

This patch changes that behavior to change the existing text/plain header to the real Content-Type instead of adding multiple Content-Type headers.