1

我知道你会不寒而栗,但这是我想做的:

我希望 html 在下载时看起来像这样:

<t><r>
  <d c="b" s="w: 1px;"></d>
  <d c="i" s="w: 99px;"></d>
  <d c="t" s="w: 1px;"></d>
  <d c="u" s="w: 6px;"></d>
<r></t>

然后在下载后用javascript修改为真正的交易:

<table><tr>
  <td class="b" style="width: 1px;"></td>
  <td class="i" style="width: 99px;"></td>
  <td class="t" style="width: 1px;"></td>
  <td class="u" style="width: 6px;"></td>
<tr></table>

这甚至可能吗?

编辑:代码的答案,因为我要到 8 小时才能回答自己的问题?!​​?!

好的,工作正常!

这是ruby​​ 的代码:

public static class Stats extends Service {
    public String path() { return "/stats.html"; }
    public void filter(Event event) throws Event, Exception {
        event.reply().header("Content-Encoding", "gzip");

        File file = new File("app/content/stats.html.gzip");
        file.createNewFile();

        GZIPOutputStream out = new GZIPOutputStream(new FileOutputStream(file));
        FileInputStream in = new FileInputStream("app/content/stats.html");

        Deploy.pipe(in, out);

        in.close();

        out.finish();
        out.close();

        in = new FileInputStream(file);

        Deploy.pipe(in, event.reply().output(file.length()));

        in.close();
    }
}

我的文件不需要性能,在这种情况下,您当然会在写入而不是读取时压缩它...

4

0 回答 0