免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 804 | 回复: 0
打印 上一主题 下一主题

A Big Bug in Heritrix ? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-09-12 15:02 |只看该作者 |倒序浏览

                                I tested ARCWriter & ARCReader of Heritrix, and I got a big problem when reading chinese content from ARC file.
I defined page and http-header :
                final String PAGE = " TEST test 测试中文 ";
                final String CONTENT = "HTTP/1.1 200 OK\r\n"
                                + "Content-Type: text/html\r\n\r\n" + PAGE;
and then write it to ARC in looping.
But there're problems When reading
I used ARCRecord.dump to dump content to console, and got this:
HTTP/1.1 200 OK
Content-Type: text/html
TEST test 测试中文  TEST test 测试中文 ";
        final String CONTENT = "HTTP/1.1 200 OK\r\n"
                + "Content-Type: text/html\r\n\r\n" + PAGE;
        ARCWriter aw = new ARCWriter(SERIAL_NO, Arrays.asList(ARC_DIRs),
                PREFIX, COMPRESS, DEFAULT_MAX_ARC_FILE_SIZE);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        baos.write(CONTENT.getBytes());
        // write first record
        aw.write(URL, TYPE, HOST, DATE, CONTENT.length(), baos);
        for (int i = 0; i  file:"
                    + aw.getFile().getAbsolutePath() + "\t offset: " + start
                    + "\t size:" + (end - start));
        }
        aw.close();
    }
        
    //NOTE:
    // change file and offset when use :
   
    public static void testARCReader() throws IOException {
        final String arcFile = "d:\\tmp\\arc1\\TMP-20070912062413-00000.arc.gz";
        ARCReader reader = ARCReaderFactory.get(new URL("file:////" + arcFile));
        ARCRecord r = (ARCRecord) reader.get(309);
        System.out.println(r.getBodyOffset());
        System.out.println(r.getHeader().getDate());
        System.out.println(r.getHeader().getLength());
        System.out.println(r.getHeader().getOffset());
        System.out.println(r.getHeader().getMimetype());
        System.out.println(r.getHeader().getUrl());
        // r.dumpHttpHeader();
        //r.skipHttpHeader();
        r.dump();
        r.close();
/*
or dump to file, got the same problem
But when I write several  r.dump()  after the first r.dump(), I got one char each time
and the whole content can be dumped till a exception happens
*/
     }
               
               
               
               
               
               
               

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u1/37897/showart_380298.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP