Пример #1
0
 private static void respond503Unavailable(HttpListenerContext ctx)
 {
     try
     {
         ctx.Response.StatusCode = (int)HttpStatusCode.ServiceUnavailable;
         using (StreamWriter w = new StreamWriter(ctx.Response.OutputStream))
         {
             Cloud.CloudResponse json = new Cloud.CloudResponse(
                 ctx.Response.StatusCode,
                 DateTime.UtcNow,
                 (int)StationApiError.ServerOffline,
                 "Server offline");
             w.Write(json.ToFastJSON());
         }
     }
     catch (Exception e)
     {
         logger.Warn("Unable to respond 503 Service Unavailable", e);
     }
 }
Пример #2
0
 private static void respond401Unauthorized(HttpListenerContext ctx)
 {
     try
     {
         ctx.Response.StatusCode = (int)HttpStatusCode.Unauthorized;
         using (StreamWriter w = new StreamWriter(ctx.Response.OutputStream))
         {
             Cloud.CloudResponse json = new Cloud.CloudResponse(
                 ctx.Response.StatusCode,
                 DateTime.UtcNow,
                 (int)StationApiError.AlreadyHasStaion,
                 "Driver already registered another station"
                 );
             w.Write(json.ToFastJSON());
         }
     }
     catch (Exception e)
     {
         logger.Warn("Unable to respond 401 Unauthorized", e);
     }
 }