Пример #1
0
        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
        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);
        }