Description
When System.Net.HttpListener.GetContext() is called after System.Net.HttpListener.Stop() on Linux, HttpListenerException with ErrorCode=HttpStatusCode.InternalServerError is thrown.
On Windows it's ErrorCode=SocketError.OperationAborted, and imo they should be aligned for all OSes.
Here is non-Windows code that throws:
|
if (_inGet && (exc is ObjectDisposedException)) |
|
_exception = new HttpListenerException((int)HttpStatusCode.InternalServerError, SR.net_listener_close); |
Reproduction Steps
.
Expected behavior
Same HttpListenerException.ExitCode on all OSes or System.InvalidOperationException, as API declares:
https://learn.microsoft.com/en-us/dotnet/api/system.net.httplistener.getcontext?view=net-10.0#exceptions
InvalidOperationException
This object has not been started or is currently stopped.
Actual behavior
When System.Net.HttpListener.GetContext() is called after System.Net.HttpListener.Stop() on Linux, HttpListenerException with ErrorCode=HttpStatusCode.InternalServerError is thrown.
On Windows it's ErrorCode=SocketError.OperationAborted.
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
No response