We have an old legacy web application, hosted in IIS, running on Windows 2019 server. For whatever unknown reason, when the user browses to the application URL, they get result:
The server provided an invalid message! Content-Length: 0
Tested using Chrome, Edge and IE, all the same. The “zero” content length is expected because this legacy web application is still using HTTP/0.9 protocol which doesn’t have HTTP header. The thing is that this is the only Windows 2019 server with this issue, all other Windows 2019 servers (other customers) work fine.
I made a PowerShell script that simulate HTTP server and output HTTP/0.9 (see below). Tested the script using IE by browsing to http://localhost:8085, and the issue was reproduced. So, the root-cause should not be IIS. And there is no web-proxy configured in the system.
So, I am wondering what the root-cause could be. I am suspecting some kind of Windows security policy blocking HTTP/0.9 protocol, but I have no idea which security policy. We tried disabling antivirus, same issue.
# HTTP/0.9 Server in PowerShell
$listener = [System.Net.Sockets.TcpListener]::new([System.Net.IPAddress]::Any, 8085)
$listener.Start()
Write-Host "Server running on port 8085..."
# Create a cancellation token source
$tokenSource = [System.Threading.CancellationTokenSource]::new()
# Function to handle Ctrl-C
function HandleCtrlC {
Write-Host "Stopping server..."
$tokenSource.Cancel()
$listener.Stop()
$listener.Server.Close()
exit
}
# Register Ctrl-C handler
$null = Register-ObjectEvent -InputObject ([System.Management.Automation.PSObject] $Host) -EventName 'Exiting' -Action {
HandleCtrlC
}
try {
while (-not $tokenSource.Token.IsCancellationRequested) {
# Check for pending client connections
if ($listener.Pending()) {
# Accept client connection
$client = $listener.AcceptTcpClient()
$stream = $client.GetStream()
$reader = [System.IO.StreamReader]::new($stream)
$writer = [System.IO.StreamWriter]::new($stream)
# Read request (for HTTP/0.9, just read the first line)
$requestLine = $reader.ReadLine()
Write-Host "Received request: $requestLine"
# Process request (for demo, always respond with Hello World + current date/time)
if ($requestLine -like "GET *") {
# Current date and time with milliseconds
$currentTime = Get-Date -Format 'yyyy-MM-dd HH:mm:ss.fff'
# HTTP/0.9 response (no headers, plain HTML content)
$response = "<html><body><h1>Hello, World! Current Time: $currentTime</h1></body></html>"
$writer.Write($response)
$writer.Flush() # Ensure the response is flushed
}
# Close the stream and the client connection
$writer.Close()
$reader.Close()
$client.Close()
}
else {
# Check for cancellation token
if ($tokenSource.Token.IsCancellationRequested) {
break
}
Start-Sleep -Milliseconds 100
}
}
}
finally {
# Clean up resources
$listener.Stop()
$listener.Server.Close()
}