Exemplo n.º 1
0
        private void CallNewProcessor(HttpListenerContext ctx)
        {
            HttpCall call = new HttpCall(ctx);

            try
            {
                prc(this, call);
            }
            catch (Exception e)
            {
                call.Response.StatusCode = 500;
                call.Write(e.GetType().Name + ": " + e.Message);
            }
            finally
            {
                call.Close();
            }
        }
Exemplo n.º 2
0
        public static void WriteResource(string path, HttpCall call)
        {
#if DEBUG
            if (EXTERNAL_RESOURCES)
            {
                call.Write(File.ReadAllBytes(Path.Combine(sfpath, path)));
                return;
            }
#endif
            byte[] data;
            if (Res.TryGetValue(path, out data))
            {
                call.Write(data, 0, data.Length);
            }
            else
            {
                throw new Exception("Resource not found");
            }
        }
Exemplo n.º 3
0
        public static void WriteTemplate(string template, HttpCall call, params object[] para)
        {
#if DEBUG
            if (EXTERNAL_RESOURCES)
            {
                InitResources();
            }
#endif
            Templater t;
            if (Templs.TryGetValue(template, out t))
            {
                call.Write(t.Process(para));
            }
#if DEBUG
            else
            {
                throw new Exception("No template found for: " + template);
            }
#endif
        }
Exemplo n.º 4
0
 public ZipDownload(HttpCall call)
 {
     this.call = call;
     temp      = new FileStream(temppath = Path.GetTempPath() + Guid.NewGuid().ToString() + ".zip", FileMode.Create, FileAccess.ReadWrite);
     z         = new ZipArchive(temp, ZipArchiveMode.Create, true, Encoding.UTF8);
 }