예제 #1
0
파일: CGIDoc.cs 프로젝트: jackfnx/bbsreader
        public void Execute(HttpListenerResponse response, params object[] paras)
        {
            packets = PacketLoader.LoadPackets();
            JsonSerializerSettings jss = new JsonSerializerSettings();

            jss.ContractResolver = new LimitPropsContractResolver(new string[] { "chapters" }, false);
            string json = JsonConvert.SerializeObject(packets, jss);

            byte[] buffer = Encoding.UTF8.GetBytes(json);
            response.ContentType     = "application/json";
            response.ContentEncoding = Encoding.UTF8;
            response.ContentLength64 = buffer.Length;
            response.OutputStream.Write(buffer, 0, buffer.Length);
        }
예제 #2
0
파일: CGICon.cs 프로젝트: jackfnx/bbsreader
        public void Execute(HttpListenerResponse response, params object[] paras)
        {
            string        key     = paras[0] as string;
            List <Packet> packets = PacketLoader.LoadPackets();

            if (!packets.Exists(x => x.key == key))
            {
                response.StatusCode = 404;
                return;
            }

            Packet packet   = packets.Find(x => x.key == key);
            string fileName = packet.key + ".zip";

            byte[] packetData = packet.source != "TextRepack" ? ZipPacket(packet) : LoadPacket(packet);

            response.ContentType = "application/zip";
            response.AddHeader("Content-Disposition", "attachment;FileName=" + fileName);
            response.ContentLength64 = packetData.Length;
            response.OutputStream.Write(packetData, 0, packetData.Length);
        }