source: binary-improvements/MapRendering/Web/API/WebAPI.cs@ 317

Last change on this file since 317 was 309, checked in by alloc, 7 years ago

Fixes 14_16_21

File size: 1.0 KB
RevLine 
[230]1using System;
2using System.Net;
3using System.Text;
4
5namespace AllocsFixes.NetConnections.Servers.Web.API
6{
7 public abstract class WebAPI
8 {
[306]9 public static void WriteJSON (HttpListenerResponse resp, JSON.JSONNode root)
[230]10 {
[309]11 StringBuilder sb = new StringBuilder ();
12 root.ToString (sb);
13 byte[] buf = Encoding.UTF8.GetBytes (sb.ToString ());
[230]14 resp.ContentLength64 = buf.Length;
15 resp.ContentType = "application/json";
16 resp.ContentEncoding = Encoding.UTF8;
17 resp.OutputStream.Write (buf, 0, buf.Length);
18 }
19
[306]20 public static void WriteText (HttpListenerResponse _resp, string _text)
21 {
22 byte[] buf = Encoding.UTF8.GetBytes (_text);
23 _resp.ContentLength64 = buf.Length;
24 _resp.ContentType = "text/plain";
25 _resp.ContentEncoding = Encoding.UTF8;
26 _resp.OutputStream.Write (buf, 0, buf.Length);
27 }
28
[244]29 public abstract void HandleRequest (HttpListenerRequest req, HttpListenerResponse resp, WebConnection user, int permissionLevel);
[279]30
31 public virtual int DefaultPermissionLevel () {
32 return 0;
33 }
[230]34 }
35}
36
Note: See TracBrowser for help on using the repository browser.