Esempio n. 1
0
 internal static string BuildErrorResponse(ConnectionErrorResult error, string httpVersion)
 {
     return(error switch
     {
         ConnectionErrorResult.AuthenticationError => $"{httpVersion} 401 Unauthorized\r\n\r\n",
         ConnectionErrorResult.HostUnreachable => $"{httpVersion} 502 {error}\r\n\r\n",
         ConnectionErrorResult.ConnectionRefused => $"{httpVersion} 502 {error}\r\n\r\n",
         ConnectionErrorResult.ConnectionReset => $"{httpVersion} 502 {error}\r\n\r\n",
         _ => $"{httpVersion} 500 Internal Server Error\r\nX-Proxy-Error-Type: {error}\r\n\r\n"
     });
Esempio n. 2
0
 private static async ValueTask SendErrorAsync(PipeWriter writer, ConnectionErrorResult error, string httpVersion = @"HTTP/1.1", CancellationToken token = default)
 {
     string str = BuildErrorResponse(error, httpVersion);
     await writer.WriteAsync(str, token);
 }