Change IResponse.Write to be async (#197)
This commit is contained in:
Родитель
71627f1e37
Коммит
1749b58da7
|
@ -1,11 +1,11 @@
|
|||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WWT.Providers
|
||||
{
|
||||
public interface IResponse
|
||||
{
|
||||
void BinaryWrite(byte[] data);
|
||||
|
||||
void End();
|
||||
|
||||
void Clear();
|
||||
|
@ -20,7 +20,7 @@ namespace WWT.Providers
|
|||
|
||||
int StatusCode { get; set; }
|
||||
|
||||
void Write(string message);
|
||||
Task WriteAsync(string message, CancellationToken token);
|
||||
|
||||
void Flush();
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ namespace WWT.Providers
|
|||
}
|
||||
|
||||
bw.Flush();
|
||||
context.Response.BinaryWrite(data);
|
||||
await context.Response.OutputStream.WriteAsync(data, 0, data.Length, token);
|
||||
}
|
||||
|
||||
context.Response.End();
|
||||
|
|
|
@ -70,7 +70,7 @@ namespace WWT.Providers
|
|||
bw.Write(sample);
|
||||
}
|
||||
bw.Flush();
|
||||
context.Response.BinaryWrite(data);
|
||||
await context.Response.OutputStream.WriteAsync(data, 0, data.Length, token);
|
||||
}
|
||||
|
||||
context.Response.End();
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace WWT.Providers
|
|||
{
|
||||
context.Response.Clear();
|
||||
context.Response.ContentType = "text/plain";
|
||||
context.Response.Write("No image");
|
||||
await context.Response.WriteAsync("No image", token);
|
||||
context.Response.End();
|
||||
}
|
||||
else
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace WWT.Providers
|
|||
{
|
||||
context.Response.Clear();
|
||||
context.Response.ContentType = "text/plain";
|
||||
context.Response.Write("No image");
|
||||
await context.Response.WriteAsync("No image", token);
|
||||
context.Response.End();
|
||||
}
|
||||
else
|
||||
|
|
|
@ -29,7 +29,7 @@ namespace WWT.Providers
|
|||
|
||||
if (level > 12)
|
||||
{
|
||||
context.Response.Write("No image");
|
||||
await context.Response.WriteAsync("No image", token);
|
||||
context.Response.Close();
|
||||
}
|
||||
else if (level < 8)
|
||||
|
|
|
@ -29,7 +29,7 @@ namespace WWT.Providers
|
|||
|
||||
if (level > 12)
|
||||
{
|
||||
context.Response.Write("No image");
|
||||
await context.Response.WriteAsync("No image", token);
|
||||
context.Response.Close();
|
||||
}
|
||||
else if (level < 8)
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace WWT.Providers
|
|||
|
||||
if (level > 20)
|
||||
{
|
||||
context.Response.Write("No image");
|
||||
await context.Response.WriteAsync("No image", token);
|
||||
context.Response.Close();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace WWT.Providers
|
|||
|
||||
if (level > 20)
|
||||
{
|
||||
context.Response.Write("No image");
|
||||
await context.Response.WriteAsync("No image", token);
|
||||
context.Response.Close();
|
||||
}
|
||||
else if (level < 8)
|
||||
|
|
|
@ -11,14 +11,12 @@ namespace WWT.Providers
|
|||
|
||||
public override string ContentType => ContentTypes.Text;
|
||||
|
||||
public override Task RunAsync(IWwtContext context, CancellationToken token)
|
||||
public override async Task RunAsync(IWwtContext context, CancellationToken token)
|
||||
{
|
||||
context.Response.Write("ClientVersion:");
|
||||
await context.Response.WriteAsync("ClientVersion:", token);
|
||||
context.Response.WriteFile(context.MapPath(Path.Combine("..", "wwt2", "ExcelAddinVersion.txt")));
|
||||
context.Response.Write("\nUpdateUrl:");
|
||||
await context.Response.WriteAsync("\nUpdateUrl:", token);
|
||||
context.Response.WriteFile(context.MapPath(Path.Combine("..", "wwt2", "ExcelAddinUpdateUrl.txt")));
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ namespace WWT.Providers
|
|||
{
|
||||
context.Response.Clear();
|
||||
context.Response.ContentType = "text/plain";
|
||||
context.Response.Write("No image");
|
||||
await context.Response.WriteAsync("No image", token);
|
||||
context.Response.End();
|
||||
}
|
||||
else
|
||||
|
|
|
@ -31,9 +31,9 @@ namespace WWT.Providers
|
|||
{
|
||||
context.Response.Clear();
|
||||
context.Response.ContentType = "text/plain";
|
||||
context.Response.Write("No image");
|
||||
await context.Response.WriteAsync("No image", token);
|
||||
context.Response.End();
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
if (level < 9)
|
||||
|
@ -54,7 +54,7 @@ namespace WWT.Providers
|
|||
{
|
||||
context.Response.Clear();
|
||||
context.Response.ContentType = "text/plain";
|
||||
context.Response.Write("No image");
|
||||
await context.Response.WriteAsync("No image", token);
|
||||
context.Response.End();
|
||||
return;
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ namespace WWT.Providers
|
|||
{
|
||||
context.Response.Clear();
|
||||
context.Response.ContentType = "text/plain";
|
||||
context.Response.Write("No image");
|
||||
await context.Response.WriteAsync("No image", token);
|
||||
context.Response.End();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace WWT.Providers
|
|||
{
|
||||
context.Response.Clear();
|
||||
context.Response.ContentType = "text/plain";
|
||||
context.Response.Write("No image");
|
||||
await context.Response.WriteAsync("No image", token);
|
||||
context.Response.End();
|
||||
return;
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ namespace WWT.Providers
|
|||
{
|
||||
context.Response.Clear();
|
||||
context.Response.ContentType = "text/plain";
|
||||
context.Response.Write("No image");
|
||||
await context.Response.WriteAsync("No image", token);
|
||||
context.Response.End();
|
||||
return;
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ namespace WWT.Providers
|
|||
{
|
||||
context.Response.Clear();
|
||||
context.Response.ContentType = "text/plain";
|
||||
context.Response.Write("No image");
|
||||
await context.Response.WriteAsync("No image", token);
|
||||
context.Response.End();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -31,9 +31,9 @@ namespace WWT.Providers
|
|||
{
|
||||
context.Response.Clear();
|
||||
context.Response.ContentType = "text/plain";
|
||||
context.Response.Write("No image");
|
||||
await context.Response.WriteAsync("No image", token);
|
||||
context.Response.End();
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
if (level < 9)
|
||||
|
@ -47,16 +47,16 @@ namespace WWT.Providers
|
|||
await s.CopyToAsync(context.Response.OutputStream, token);
|
||||
context.Response.Flush();
|
||||
context.Response.End();
|
||||
return;
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
context.Response.Clear();
|
||||
context.Response.ContentType = "text/plain";
|
||||
context.Response.Write("No image");
|
||||
await context.Response.WriteAsync("No image", token);
|
||||
context.Response.End();
|
||||
return;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -85,9 +85,9 @@ namespace WWT.Providers
|
|||
{
|
||||
context.Response.Clear();
|
||||
context.Response.ContentType = "text/plain";
|
||||
context.Response.Write("No image");
|
||||
await context.Response.WriteAsync("No image", token);
|
||||
context.Response.End();
|
||||
return;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,8 +10,7 @@ namespace WWT.Providers
|
|||
|
||||
public override Task RunAsync(IWwtContext context, CancellationToken token)
|
||||
{
|
||||
context.Response.Write(context.MachineName);
|
||||
return Task.CompletedTask;
|
||||
return context.Response.WriteAsync(context.MachineName, token);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace WWT.Providers
|
|||
|
||||
public override string ContentType => ContentTypes.Png;
|
||||
|
||||
public override Task RunAsync(IWwtContext context, CancellationToken token)
|
||||
public override async Task RunAsync(IWwtContext context, CancellationToken token)
|
||||
{
|
||||
string path = context.MapPath(@"TourCache");
|
||||
|
||||
|
@ -61,10 +61,8 @@ namespace WWT.Providers
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
context.Response.Write(e.Message);
|
||||
await context.Response.WriteAsync(e.Message, token);
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace WWT.Providers
|
|||
|
||||
public override bool IsCacheable => false;
|
||||
|
||||
public override Task RunAsync(IWwtContext context, CancellationToken token)
|
||||
public override async Task RunAsync(IWwtContext context, CancellationToken token)
|
||||
{
|
||||
string etag = context.Request.Headers["If-None-Match"];
|
||||
UpdateCacheEx(context.Cache);
|
||||
|
@ -29,7 +29,7 @@ namespace WWT.Providers
|
|||
if (newEtag != etag)
|
||||
{
|
||||
context.Response.AddHeader("etag", newEtag);
|
||||
context.Response.Write(toursXML);
|
||||
await context.Response.WriteAsync(toursXML, token);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -37,8 +37,6 @@ namespace WWT.Providers
|
|||
}
|
||||
}
|
||||
context.Response.End();
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
protected override string SqlCommandString => "Select CategoryId, ParentCatID, Name, CatThumbnailUrl from TourCategories where ParentCatId = ";
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace WWT.Providers
|
|||
|
||||
public override bool IsCacheable => false;
|
||||
|
||||
public override Task RunAsync(IWwtContext context, CancellationToken token)
|
||||
public override async Task RunAsync(IWwtContext context, CancellationToken token)
|
||||
{
|
||||
string etag = context.Request.Headers["If-None-Match"];
|
||||
UpdateCacheEx(context.Cache);
|
||||
|
@ -33,7 +33,7 @@ namespace WWT.Providers
|
|||
if (newEtag != etag)
|
||||
{
|
||||
context.Response.AddHeader("etag", newEtag);
|
||||
context.Response.Write(toursXML);
|
||||
await context.Response.WriteAsync(toursXML, token);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -41,8 +41,6 @@ namespace WWT.Providers
|
|||
}
|
||||
}
|
||||
context.Response.End();
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
protected override void LoadTourFromRow(DataRow dr, Tour tr)
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace WWT.Providers
|
|||
{
|
||||
context.Response.Clear();
|
||||
context.Response.ContentType = "text/plain";
|
||||
context.Response.Write("No image");
|
||||
await context.Response.WriteAsync("No image", token);
|
||||
context.Response.End();
|
||||
return;
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ namespace WWT.Providers
|
|||
{
|
||||
context.Response.Clear();
|
||||
context.Response.ContentType = "text/plain";
|
||||
context.Response.Write("No image");
|
||||
await context.Response.WriteAsync("No image", token);
|
||||
context.Response.End();
|
||||
return;
|
||||
}
|
||||
|
@ -83,16 +83,16 @@ namespace WWT.Providers
|
|||
s.CopyTo(context.Response.OutputStream);
|
||||
context.Response.Flush();
|
||||
context.Response.End();
|
||||
return;
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
context.Response.Clear();
|
||||
context.Response.ContentType = "text/plain";
|
||||
context.Response.Write("No image");
|
||||
await context.Response.WriteAsync("No image", token);
|
||||
context.Response.End();
|
||||
return;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,9 +36,7 @@ namespace WWT.Providers
|
|||
}
|
||||
|
||||
string xml = string.Format("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Folder Group=\"Goto\">\n<Place Name=\"{0}\" RA=\"{1}\" Dec=\"{2}\" ZoomLevel=\"{3}\" DataSetType=\"Sky\"/>\n</Folder>", name, ra, dec, zoom);
|
||||
context.Response.Write(xml);
|
||||
|
||||
return Task.CompletedTask;
|
||||
return context.Response.WriteAsync(xml, token);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,9 +36,8 @@ namespace WWT.Providers
|
|||
}
|
||||
|
||||
string xml = string.Format("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Folder Group=\"Goto\">\n<Place Name=\"{0}\" RA=\"{1}\" Dec=\"{2}\" ZoomLevel=\"{3}\" DataSetType=\"Sky\"/>\n</Folder>", name, ra, dec, zoom);
|
||||
context.Response.Write(xml);
|
||||
|
||||
return Task.CompletedTask;
|
||||
return context.Response.WriteAsync(xml, token);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace WWT.Providers
|
|||
{
|
||||
context.Response.Clear();
|
||||
context.Response.ContentType = "text/plain";
|
||||
context.Response.Write("No image");
|
||||
await context.Response.WriteAsync("No image", token);
|
||||
context.Response.End();
|
||||
return;
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ namespace WWT.Providers
|
|||
{
|
||||
context.Response.Clear();
|
||||
context.Response.ContentType = "text/plain";
|
||||
context.Response.Write("No image");
|
||||
await context.Response.WriteAsync("No image", token);
|
||||
context.Response.End();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ namespace WWT.Providers
|
|||
{
|
||||
context.Response.Clear();
|
||||
context.Response.ContentType = "text/plain";
|
||||
context.Response.Write("No image");
|
||||
await context.Response.WriteAsync("No image", token);
|
||||
context.Response.End();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ namespace WWT.Providers
|
|||
{
|
||||
context.Response.Clear();
|
||||
context.Response.ContentType = "text/plain";
|
||||
context.Response.Write("No image");
|
||||
await context.Response.WriteAsync("No image", token);
|
||||
context.Response.End();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ namespace WWT.Providers
|
|||
{
|
||||
context.Response.Clear();
|
||||
context.Response.ContentType = "text/plain";
|
||||
context.Response.Write("No image");
|
||||
await context.Response.WriteAsync("No image", token);
|
||||
context.Response.End();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace WWT.Providers
|
|||
{
|
||||
public override string ContentType => ContentTypes.Text;
|
||||
|
||||
public override Task RunAsync(IWwtContext context, CancellationToken token)
|
||||
public override async Task RunAsync(IWwtContext context, CancellationToken token)
|
||||
{
|
||||
string url = "";
|
||||
|
||||
|
@ -77,21 +77,18 @@ namespace WWT.Providers
|
|||
context.Cache["WWTISSTLDATE"] = DateTime.Now;
|
||||
}
|
||||
}
|
||||
context.Response.Write(reply);
|
||||
|
||||
await context.Response.WriteAsync(reply, token);
|
||||
}
|
||||
catch (System.Exception)
|
||||
catch (Exception)
|
||||
{
|
||||
string reply = "1 25544U 98067A 13274.85334491 .00007046 00000-0 12878-3 0 7167\n";
|
||||
reply += "2 25544 51.6486 299.7368 0003212 97.7461 254.0523 15.50562392851247\n";
|
||||
reply += "Cached during NASA Downtime";
|
||||
|
||||
|
||||
// returnString = e.Message;
|
||||
context.Response.Write(reply);
|
||||
await context.Response.WriteAsync(reply, token);
|
||||
}
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace WWT.Providers
|
|||
{
|
||||
public override string ContentType => ContentTypes.Text;
|
||||
|
||||
public override Task RunAsync(IWwtContext context, CancellationToken token)
|
||||
public override async Task RunAsync(IWwtContext context, CancellationToken token)
|
||||
{
|
||||
string url = "";
|
||||
|
||||
|
@ -69,21 +69,18 @@ namespace WWT.Providers
|
|||
context.Cache["WWTISSTLDATE"] = DateTime.Now;
|
||||
}
|
||||
}
|
||||
context.Response.Write(reply);
|
||||
|
||||
await context.Response.WriteAsync(reply, token);
|
||||
}
|
||||
catch (System.Exception)
|
||||
catch (Exception)
|
||||
{
|
||||
string reply = "1 25544U 98067A 13274.85334491 .00007046 00000-0 12878-3 0 7167\n";
|
||||
reply += "2 25544 51.6486 299.7368 0003212 97.7461 254.0523 15.50562392851247\n";
|
||||
reply += "Cached during NASA Downtime";
|
||||
|
||||
|
||||
// returnString = e.Message;
|
||||
context.Response.Write(reply);
|
||||
await context.Response.WriteAsync(reply, token);
|
||||
}
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace WWT.Providers
|
|||
|
||||
public override bool IsCacheable => false;
|
||||
|
||||
public override Task RunAsync(IWwtContext context, CancellationToken token)
|
||||
public override async Task RunAsync(IWwtContext context, CancellationToken token)
|
||||
{
|
||||
context.Response.Expires = -1;
|
||||
context.Response.AddHeader("etag", "1-2-3-4-5");
|
||||
|
@ -27,21 +27,21 @@ namespace WWT.Providers
|
|||
if (context.Request.Params["Equinox"] != null)
|
||||
{
|
||||
context.Response.WriteFile(context.MapPath("wwt2", "EqClientVersion.txt"));
|
||||
context.Response.Write("\n");
|
||||
await context.Response.WriteAsync("\n", token);
|
||||
}
|
||||
else
|
||||
{
|
||||
context.Response.Write("ClientVersion:");
|
||||
await context.Response.WriteAsync("ClientVersion:",token);
|
||||
context.Response.WriteFile(context.MapPath("wwt2", "ClientVersion.txt"));
|
||||
context.Response.Write("\n");
|
||||
await context.Response.WriteAsync("\n", token);
|
||||
context.Response.WriteFile(context.MapPath("wwt2", "dataversion.txt"));
|
||||
context.Response.Write("\nMessage:");
|
||||
await context.Response.WriteAsync("\nMessage:", token);
|
||||
context.Response.WriteFile(context.MapPath("wwt2", "message.txt"));
|
||||
context.Response.Write("\nWarnVersion:");
|
||||
await context.Response.WriteAsync("\nWarnVersion:", token);
|
||||
context.Response.WriteFile(context.MapPath("wwt2", "warnver.txt"));
|
||||
context.Response.Write("\nMinVersion:");
|
||||
await context.Response.WriteAsync("\nMinVersion:", token);
|
||||
context.Response.WriteFile(context.MapPath("wwt2", "minver.txt"));
|
||||
context.Response.Write("\nUpdateUrl:");
|
||||
await context.Response.WriteAsync("\nUpdateUrl:", token);
|
||||
context.Response.WriteFile(context.MapPath("wwt2", "updateurl.txt"));
|
||||
}
|
||||
context.Response.Flush();
|
||||
|
@ -61,8 +61,6 @@ namespace WWT.Providers
|
|||
catch
|
||||
{
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,15 +41,15 @@ namespace WWT.Providers
|
|||
{
|
||||
context.Response.Clear();
|
||||
context.Response.ContentType = "text/plain";
|
||||
context.Response.Write("No image");
|
||||
await context.Response.WriteAsync("No image", token);
|
||||
context.Response.End();
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
await s.CopyToAsync(context.Response.OutputStream, token);
|
||||
context.Response.Flush();
|
||||
context.Response.End();
|
||||
return;
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -69,14 +69,14 @@ namespace WWT.Providers
|
|||
{
|
||||
context.Response.Clear();
|
||||
context.Response.ContentType = "text/plain";
|
||||
context.Response.Write("No image");
|
||||
await context.Response.WriteAsync("No image", token);
|
||||
context.Response.End();
|
||||
return;
|
||||
}
|
||||
await s.CopyToAsync(context.Response.OutputStream, token);
|
||||
context.Response.Flush();
|
||||
context.Response.End();
|
||||
return;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,15 +94,15 @@ namespace WWT.Providers
|
|||
{
|
||||
context.Response.Clear();
|
||||
context.Response.ContentType = "text/plain";
|
||||
context.Response.Write("No image");
|
||||
await context.Response.WriteAsync("No image", token);
|
||||
context.Response.End();
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
await s.CopyToAsync(context.Response.OutputStream, token);
|
||||
context.Response.Flush();
|
||||
context.Response.End();
|
||||
return;
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -41,7 +41,7 @@ namespace WWT.Providers
|
|||
{
|
||||
context.Response.Clear();
|
||||
context.Response.ContentType = "text/plain";
|
||||
context.Response.Write("No image");
|
||||
await context.Response.WriteAsync("No image", token);
|
||||
context.Response.End();
|
||||
}
|
||||
else
|
||||
|
@ -61,7 +61,7 @@ namespace WWT.Providers
|
|||
{
|
||||
context.Response.Clear();
|
||||
context.Response.ContentType = "text/plain";
|
||||
context.Response.Write("No image");
|
||||
await context.Response.WriteAsync("No image", token);
|
||||
context.Response.End();
|
||||
}
|
||||
else
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace WWT.Providers
|
|||
{
|
||||
context.Response.Clear();
|
||||
context.Response.ContentType = "text/plain";
|
||||
context.Response.Write("No image");
|
||||
await context.Response.WriteAsync("No image", token);
|
||||
context.Response.End();
|
||||
return;
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ namespace WWT.Providers
|
|||
{
|
||||
context.Response.Clear();
|
||||
context.Response.ContentType = "text/plain";
|
||||
context.Response.Write("No image");
|
||||
await context.Response.WriteAsync("No image", token);
|
||||
context.Response.End();
|
||||
return;
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ namespace WWT.Providers
|
|||
{
|
||||
context.Response.Clear();
|
||||
context.Response.ContentType = "text/plain";
|
||||
context.Response.Write("No image");
|
||||
await context.Response.WriteAsync("No image", token);
|
||||
context.Response.End();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace WWT.Providers
|
|||
|
||||
if (level > 10)
|
||||
{
|
||||
context.Response.Write("No image");
|
||||
await context.Response.WriteAsync("No image", token);
|
||||
context.Response.Close();
|
||||
return; ;
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace WWT.Providers
|
|||
|
||||
if (level > 10)
|
||||
{
|
||||
context.Response.Write("No image");
|
||||
await context.Response.WriteAsync("No image", token);
|
||||
context.Response.Close();
|
||||
return; ;
|
||||
}
|
||||
|
|
|
@ -12,8 +12,7 @@ namespace WWT.Providers
|
|||
|
||||
public override Task RunAsync(IWwtContext context, CancellationToken token)
|
||||
{
|
||||
context.Response.Write("OK");
|
||||
return Task.CompletedTask;
|
||||
return context.Response.WriteAsync("OK", token);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace WWT.Providers
|
|||
{
|
||||
if (context.Request.UserAgent.ToLower().Contains("wget"))
|
||||
{
|
||||
context.Response.Write("You are not allowed to bulk download imagery thru the tile service. Please contact wwtpage@microsoft.com for more information.");
|
||||
await context.Response.WriteAsync("You are not allowed to bulk download imagery thru the tile service. Please contact wwtpage@microsoft.com for more information.", token);
|
||||
context.Response.End();
|
||||
return;
|
||||
}
|
||||
|
@ -47,14 +47,14 @@ namespace WWT.Providers
|
|||
}
|
||||
catch
|
||||
{
|
||||
context.Response.Write("Invalid query string.");
|
||||
await context.Response.WriteAsync("Invalid query string.", token);
|
||||
context.Response.End();
|
||||
return;
|
||||
}
|
||||
|
||||
if (level > 14)
|
||||
{
|
||||
context.Response.Write("No image");
|
||||
await context.Response.WriteAsync("No image", token);
|
||||
context.Response.End();
|
||||
return;
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ namespace WWT.Providers
|
|||
{
|
||||
context.Response.Clear();
|
||||
context.Response.ContentType = "text/plain";
|
||||
context.Response.Write("No image");
|
||||
await context.Response.WriteAsync("No image", token);
|
||||
context.Response.End();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -10,8 +10,7 @@ namespace WWT.Providers
|
|||
|
||||
public override Task RunAsync(IWwtContext context, CancellationToken token)
|
||||
{
|
||||
context.Response.Write("Hello");
|
||||
return Task.CompletedTask;
|
||||
return context.Response.WriteAsync("Hello", token);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace WWT.Providers
|
|||
|
||||
if (level > 14)
|
||||
{
|
||||
context.Response.Write("No image");
|
||||
await context.Response.WriteAsync("No image", token);
|
||||
context.Response.Close();
|
||||
return;
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ namespace WWT.Providers
|
|||
{
|
||||
if (stream is null)
|
||||
{
|
||||
context.Response.Write("No Image");
|
||||
await context.Response.WriteAsync("No image", token);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace WWT.Providers
|
|||
{
|
||||
if (context.Request.UserAgent.ToLower().Contains("wget"))
|
||||
{
|
||||
context.Response.Write("You are not allowed to bulk download imagery thru the tile service. Please contact wwtpage@microsoft.com for more information.");
|
||||
await context.Response.WriteAsync("You are not allowed to bulk download imagery thru the tile service. Please contact wwtpage@microsoft.com for more information.", token);
|
||||
context.Response.End();
|
||||
return;
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ namespace WWT.Providers
|
|||
}
|
||||
catch
|
||||
{
|
||||
context.Response.Write("Invalid query string.");
|
||||
await context.Response.WriteAsync("Invalid query string.", token);
|
||||
context.Response.End();
|
||||
return;
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ namespace WWT.Providers
|
|||
|
||||
if (level > 14)
|
||||
{
|
||||
context.Response.Write("No image");
|
||||
await context.Response.WriteAsync("No image", token);
|
||||
context.Response.End();
|
||||
return;
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ namespace WWT.Providers
|
|||
{
|
||||
context.Response.Clear();
|
||||
context.Response.ContentType = "text/plain";
|
||||
context.Response.Write("No image");
|
||||
await context.Response.WriteAsync("No image", token);
|
||||
context.Response.End();
|
||||
return;
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ namespace WWT.Providers
|
|||
{
|
||||
if (stream is null)
|
||||
{
|
||||
context.Response.Write("No Image");
|
||||
await context.Response.WriteAsync("No image", token);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -10,12 +10,12 @@ namespace WWT.Providers
|
|||
{
|
||||
public override string ContentType => ContentTypes.XWtml;
|
||||
|
||||
public override Task RunAsync(IWwtContext context, CancellationToken token)
|
||||
public override async Task RunAsync(IWwtContext context, CancellationToken token)
|
||||
{
|
||||
if (context.Request.ContainsCookie("alphakey"))
|
||||
{
|
||||
context.Response.Redirect("http://www.worldwidetelescope.org/webclient/default.aspx?Wtml=" + WebUtility.UrlEncode(context.Request.Url.ToString() + "&wtml=true"));
|
||||
return Task.CompletedTask;
|
||||
return;
|
||||
}
|
||||
|
||||
if (context.Request.Params["debug"] != null)
|
||||
|
@ -105,9 +105,7 @@ namespace WWT.Providers
|
|||
//string xml = string.Format("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Folder Group=\"Goto\">\n<Place Name=\"{0}\" RA=\"{1}\" Dec=\"{2}\" ZoomLevel=\"{3}\" DataSetType=\"Sky\"/>\n</Folder>", name, ra, dec, zoom);
|
||||
string xml = string.Format("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Folder Name=\"{0}\" Group=\"{14}\">\n<Place Name=\"{0}\" RA=\"{1}\" Dec=\"{2}\" ZoomLevel=\"{3}\" DataSetType=\"Sky\" Opacity=\"100\" Thumbnail=\"{10}\" Constellation=\"\">\n <ForegroundImageSet>\n <ImageSet DataSetType=\"Sky\" BandPass=\"Visible\" Url=\"{8}\" TileLevels=\"0\" WidthFactor=\"2\" Rotation=\"{5}\" Projection=\"SkyImage\" FileType=\".tif\" CenterY=\"{2}\" CenterX=\"{9}\" BottomsUp=\"{13}\" OffsetX=\"{6}\" OffsetY=\"{7}\" BaseTileLevel=\"0\" BaseDegreesPerTile=\"{4}\">\n<Credits>{11}</Credits>\n<CreditsUrl>{12}</CreditsUrl>\n</ImageSet>\n</ForegroundImageSet>\n</Place>\n</Folder>", name, ra / 15, dec, zoom, scale, rotation, x, y, url, ra, thumb, credits, creditsUrl, reverseparity, bgoto ? "Goto" : "Search");
|
||||
|
||||
context.Response.Write(xml);
|
||||
|
||||
return Task.CompletedTask;
|
||||
await context.Response.WriteAsync(xml, token);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,12 +10,12 @@ namespace WWT.Providers
|
|||
{
|
||||
public override string ContentType => ContentTypes.XWtml;
|
||||
|
||||
public override Task RunAsync(IWwtContext context, CancellationToken token)
|
||||
public override async Task RunAsync(IWwtContext context, CancellationToken token)
|
||||
{
|
||||
if (!context.Request.ContainsCookie("fullclient") && context.Request.Params["wtml"] == null)
|
||||
{
|
||||
context.Response.Redirect("http://www.worldwidetelescope.org/webclient/default.aspx?wtml=" + WebUtility.UrlEncode(context.Request.Url.ToString().Replace(",", "-") + "&wtml=true"));
|
||||
return Task.CompletedTask;
|
||||
return;
|
||||
}
|
||||
|
||||
if (context.Request.Params["debug"] != null)
|
||||
|
@ -109,9 +109,7 @@ namespace WWT.Providers
|
|||
//string xml = string.Format("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Folder Group=\"Goto\">\n<Place Name=\"{0}\" RA=\"{1}\" Dec=\"{2}\" ZoomLevel=\"{3}\" DataSetType=\"Sky\"/>\n</Folder>", name, ra, dec, zoom);
|
||||
string xml = string.Format("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Folder Name=\"{0}\" Group=\"{14}\">\n<Place Name=\"{0}\" RA=\"{1}\" Dec=\"{2}\" ZoomLevel=\"{3}\" DataSetType=\"Sky\" Opacity=\"100\" Thumbnail=\"{10}\" Constellation=\"\">\n <ForegroundImageSet>\n <ImageSet DataSetType=\"Sky\" BandPass=\"Visible\" Url=\"{8}\" TileLevels=\"0\" WidthFactor=\"2\" Rotation=\"{5}\" Projection=\"SkyImage\" FileType=\".tif\" CenterY=\"{2}\" CenterX=\"{9}\" BottomsUp=\"{13}\" OffsetX=\"{6}\" OffsetY=\"{7}\" BaseTileLevel=\"0\" BaseDegreesPerTile=\"{4}\">\n<Credits>{11}</Credits>\n<CreditsUrl>{12}</CreditsUrl>\n</ImageSet>\n</ForegroundImageSet>\n</Place>\n</Folder>", name, ra / 15, dec, zoom, scale, rotation, x, y, url, ra, thumb, credits, creditsUrl, reverseparity, bgoto ? "Goto" : "Search");
|
||||
|
||||
context.Response.Write(xml);
|
||||
|
||||
return Task.CompletedTask;
|
||||
await context.Response.WriteAsync(xml, token);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,8 +17,7 @@ namespace WWT.Providers
|
|||
|
||||
public override Task RunAsync(IWwtContext context, CancellationToken token)
|
||||
{
|
||||
context.Response.Write(_options.DssToastPng);
|
||||
return Task.CompletedTask;
|
||||
return context.Response.WriteAsync(_options.DssToastPng, token);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,8 +19,7 @@ namespace WWT.Providers
|
|||
public override Task RunAsync(IWwtContext context, CancellationToken token)
|
||||
{
|
||||
String baseName = _options.WwtToursTourFileUNC.ToLower();
|
||||
context.Response.Write(baseName);
|
||||
return Task.CompletedTask;
|
||||
return context.Response.WriteAsync(baseName, token);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -153,7 +153,7 @@ namespace WWT.Providers
|
|||
|
||||
string xml = string.Format("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Folder Name=\"{0}\" Group=\"{14}\">\n<Place Name=\"{0}\" RA=\"{1}\" Dec=\"{2}\" ZoomLevel=\"{3}\" DataSetType=\"Sky\" Opacity=\"100\" Thumbnail=\"{10}\" Constellation=\"\">\n <ForegroundImageSet>\n <ImageSet DataSetType=\"Sky\" Name=\"{0}\" BandPass=\"Visible\" Url=\"http://www.worldwidetelescope.org/wwtweb/GetTile.aspx?q={{1}},{{2}},{{3}},{8}\" TileLevels=\"{15}\" WidthFactor=\"1\" Rotation=\"{5}\" Projection=\"Tan\" FileType=\".png\" CenterY=\"{2}\" CenterX=\"{9}\" BottomsUp=\"{13}\" OffsetX=\"{6}\" OffsetY=\"{7}\" BaseTileLevel=\"0\" BaseDegreesPerTile=\"{4}\">\n<Credits>{11}</Credits>\n<CreditsUrl>{12}</CreditsUrl>\n<ThumbnailUrl>{10}</ThumbnailUrl>\n</ImageSet>\n</ForegroundImageSet>\n</Place>\n</Folder>", name, ra / 15, dec, zoom, scale, rotation, x, y, id, ra, thumb, credits, creditsUrl, reverseparity, "Explorer", maxLevels);
|
||||
|
||||
context.Response.Write(xml);
|
||||
await context.Response.WriteAsync(xml, token);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ namespace WWT.Providers
|
|||
{
|
||||
context.Response.Clear();
|
||||
context.Response.ContentType = "text/plain";
|
||||
context.Response.Write("No image");
|
||||
await context.Response.WriteAsync("No image", token);
|
||||
context.Response.End();
|
||||
}
|
||||
else
|
||||
|
|
|
@ -45,7 +45,7 @@ namespace WWT.Providers
|
|||
{
|
||||
context.Response.Clear();
|
||||
context.Response.ContentType = "text/plain";
|
||||
context.Response.Write("No image");
|
||||
await context.Response.WriteAsync("No image", token);
|
||||
context.Response.End();
|
||||
}
|
||||
else
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace WWT.Providers
|
|||
{
|
||||
context.Response.Clear();
|
||||
context.Response.ContentType = "text/plain";
|
||||
context.Response.Write("No image");
|
||||
await context.Response.WriteAsync("No image", token);
|
||||
context.Response.End();
|
||||
return;;
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ namespace WWT.Providers
|
|||
{
|
||||
context.Response.Clear();
|
||||
context.Response.ContentType = "text/plain";
|
||||
context.Response.Write("No image");
|
||||
await context.Response.WriteAsync("No image", token);
|
||||
context.Response.End();
|
||||
return;;
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace WWT.Providers
|
|||
|
||||
if (query is null)
|
||||
{
|
||||
context.Response.Write("No image");
|
||||
await context.Response.WriteAsync("No image", token);
|
||||
context.Response.End();
|
||||
return;
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ namespace WWT.Providers
|
|||
|
||||
if (level > 20)
|
||||
{
|
||||
context.Response.Write("No image");
|
||||
await context.Response.WriteAsync("No image", token);
|
||||
context.Response.Close();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -11,18 +11,16 @@ namespace WWT.Providers
|
|||
|
||||
public override bool IsCacheable => false;
|
||||
|
||||
public override Task RunAsync(IWwtContext context, CancellationToken token)
|
||||
public override async Task RunAsync(IWwtContext context, CancellationToken token)
|
||||
{
|
||||
var wwt2dir = context.MapPath(Path.Combine("..", "wwt2"));
|
||||
|
||||
context.Response.Write("ClientVersion:");
|
||||
await context.Response.WriteAsync("ClientVersion:", token);
|
||||
context.Response.WriteFile(Path.Combine(wwt2dir, "version.txt"));
|
||||
context.Response.Write("\n");
|
||||
await context.Response.WriteAsync("\n", token);
|
||||
context.Response.WriteFile(Path.Combine(wwt2dir, "dataversion.txt"));
|
||||
context.Response.Write("\nMessage:");
|
||||
await context.Response.WriteAsync("\nMessage:", token);
|
||||
context.Response.WriteFile(Path.Combine(wwt2dir, "message.txt"));
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace WWT.Providers
|
|||
|
||||
public override bool IsCacheable => false;
|
||||
|
||||
public override Task RunAsync(IWwtContext context, CancellationToken token)
|
||||
public override async Task RunAsync(IWwtContext context, CancellationToken token)
|
||||
{
|
||||
context.Response.Expires = -1;
|
||||
|
||||
|
@ -23,7 +23,7 @@ namespace WWT.Providers
|
|||
string testkey = context.Request.Params["webkey"];
|
||||
if (key == testkey)
|
||||
{
|
||||
context.Response.Write("Key:Authorized");
|
||||
await context.Response.WriteAsync("Key:Authorized", token);
|
||||
if (_options.LoginTracking)
|
||||
{
|
||||
byte platform = 2;
|
||||
|
@ -56,10 +56,8 @@ namespace WWT.Providers
|
|||
}
|
||||
else
|
||||
{
|
||||
context.Response.Write("Key:Failed");
|
||||
await context.Response.WriteAsync("Key:Failed", token);
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace WWT.Providers
|
|||
{
|
||||
public override string ContentType => ContentTypes.Text;
|
||||
|
||||
public override Task RunAsync(IWwtContext context, CancellationToken token)
|
||||
public override async Task RunAsync(IWwtContext context, CancellationToken token)
|
||||
{
|
||||
string returnString = "Erorr: No URL Specified";
|
||||
string url = "";
|
||||
|
@ -38,11 +38,9 @@ namespace WWT.Providers
|
|||
catch (System.Exception e)
|
||||
{
|
||||
returnString = e.Message;
|
||||
context.Response.Write(returnString);
|
||||
await context.Response.WriteAsync(returnString, token);
|
||||
}
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Web.Caching;
|
||||
using WWT.Providers;
|
||||
|
@ -90,14 +92,19 @@ namespace WWTMVC5
|
|||
set => _context.Response.CacheControl = value;
|
||||
}
|
||||
void IResponse.AddHeader(string name, string value) => _context.Response.AddHeader(name, value);
|
||||
void IResponse.BinaryWrite(byte[] data) => _context.Response.BinaryWrite(data);
|
||||
void IResponse.Clear() => _context.Response.Clear();
|
||||
void IResponse.ClearHeaders() => _context.Response.ClearHeaders();
|
||||
void IResponse.Close() => _context.Response.Close();
|
||||
void IResponse.End() => _context.Response.End();
|
||||
void IResponse.Flush() => _context.Response.Flush();
|
||||
void IResponse.Redirect(string redirectUri) => _context.Response.Redirect(redirectUri);
|
||||
void IResponse.Write(string message) => _context.Response.Write(message);
|
||||
|
||||
Task IResponse.WriteAsync(string message, CancellationToken token)
|
||||
{
|
||||
_context.Response.Write(message);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
void IResponse.WriteFile(string path) => _context.Response.WriteFile(path);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -735,7 +735,6 @@
|
|||
<Folder Include="Views\Home\" />
|
||||
<Folder Include="Views\Resources\" />
|
||||
<Folder Include="Views\WCF\" />
|
||||
<Folder Include="WWTWeb\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Content\CSS\bootswatch.less" />
|
||||
|
|
|
@ -40,7 +40,7 @@ namespace WWT.Providers.Tests
|
|||
|
||||
protected override void ExpectedResponseAboveMaxLevel(IResponse response)
|
||||
{
|
||||
response.Received(1).Write("No image");
|
||||
response.Received(1).WriteAsync("No image", default);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ namespace WWT.Providers.Tests
|
|||
|
||||
protected override void ExpectedResponseAboveMaxLevel(IResponse response)
|
||||
{
|
||||
response.Received(1).Write("No image");
|
||||
response.Received(1).WriteAsync("No image", default);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,13 +28,13 @@ namespace WWT.Providers.Tests
|
|||
|
||||
protected virtual Action<IResponse> StreamExceptionResponseHandler { get; } = response =>
|
||||
{
|
||||
response.Received(1).Write("No image");
|
||||
response.Received(1).WriteAsync("No image", default);
|
||||
Assert.Equal("text/plain", response.ContentType);
|
||||
};
|
||||
|
||||
protected virtual Action<IResponse> NullStreamResponseHandler { get; } = response =>
|
||||
{
|
||||
response.Received(1).Write("No image");
|
||||
response.Received(1).WriteAsync("No image", default);
|
||||
Assert.Equal("text/plain", response.ContentType);
|
||||
};
|
||||
|
||||
|
@ -42,7 +42,7 @@ namespace WWT.Providers.Tests
|
|||
|
||||
protected virtual void ExpectedResponseAboveMaxLevel(IResponse response)
|
||||
{
|
||||
response.Received(1).Write("No image");
|
||||
response.Received(1).WriteAsync("No image", default);
|
||||
Assert.Equal("text/plain", response.ContentType);
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче