Package org.archive.io.warc

Examples of org.archive.io.warc.WARCRecordInfo


     * @throws Exception
     */
    public void testResourceRecord() throws Exception {
        final String ct = "text/plain";
        final byte[] block = "blahblahblah\n".getBytes();
        WARCRecordInfo recinfo = new TestWARCRecordInfo(block);
        recinfo.setType(WARCRecordType.resource);
        recinfo.setUrl("ftp://ftp.example.com/afile.txt");
        recinfo.setMimetype(ct);
        ArchiveReader ar = new TestWARCReader(recinfo);
        WARCRecord rec = (WARCRecord)ar.get(0);
        WarcResource res = new WarcResource(rec, ar);
        res.parseHeaders();
               
View Full Code Here


    cut.setSelectors(Arrays.asList(SELECTORS));
  }

  public static Resource createTestTextResource(String ctype, byte[] payloadBytes)
      throws IOException {
    WARCRecordInfo recinfo = TestWARCRecordInfo.createHttpResponse(ctype,
      payloadBytes);
    TestWARCReader ar = new TestWARCReader(recinfo);
    WARCRecord rec = ar.get(0);
    WarcResource resource = new WarcResource(rec, ar);
    resource.parseHeaders();
View Full Code Here

     * plain HTTP response, without transfer/content-encoding.
     * @throws Exception
     */
    public void testPlainHttpRecord() throws Exception {
        String payload = "hogehogehogehogehoge";
        WARCRecordInfo recinfo = TestWARCRecordInfo.createHttpResponse(payload);
        recinfo.setMimetype("text/plain");
        TestARCReader ar = new TestARCReader(recinfo);
        ARCRecord rec = ar.get(0);
        ArcResource res = new ArcResource(rec, ar);
        res.parseHeaders();
       
View Full Code Here

     * uncompressed, but chunked-encoded HTTP response.
     * @throws Exception
     */
    public void testPlainChunkedHttpRecord() throws Exception {
        String payload = "hogehogehogehogehoge";
        WARCRecordInfo recinfo = new TestWARCRecordInfo(
                TestWARCRecordInfo.buildHttpResponseBlock("200 OK",
                        "text/plain", payload.getBytes("UTF-8"), true));
        recinfo.setMimetype("text/plain");
        TestARCReader ar = new TestARCReader(recinfo);
        ARCRecord rec = ar.get(0);
        ArcResource res = new ArcResource(rec, ar);
        res.parseHeaders();
       
View Full Code Here

     * @throws Exception
     */
    public void testCompressedHttpRecord() throws Exception {
        String payload = "hogehogehogehogehoge";
        String ctype = "text/plain";
        WARCRecordInfo recinfo = new TestWARCRecordInfo(
                TestWARCRecordInfo.buildCompressedHttpResponseBlock(ctype,
                        payload.getBytes()));
        recinfo.setMimetype(ctype);
        TestARCReader ar = new TestARCReader(recinfo);
        ARCRecord rec = ar.get(0);
        ArcResource res = new ArcResource(rec, ar);
        res.parseHeaders();
       
View Full Code Here

     * @throws Exception
     */
    public void testCompressedChunkedHttpRecord() throws Exception {
        String payload = "hogehogehogehogehoge";
        String ctype = "text/plain";
        WARCRecordInfo recinfo = new TestWARCRecordInfo(
                TestWARCRecordInfo.buildCompressedHttpResponseBlock(ctype,
                        payload.getBytes(), true));
        recinfo.setMimetype(ctype);
        TestARCReader ar = new TestARCReader(recinfo);
        ARCRecord rec = ar.get(0);
        ArcResource res = new ArcResource(rec, ar);
        res.parseHeaders();
       
View Full Code Here

        }
    }
   
    public void testRenderResource_BasicCapture() throws Exception {
        final String ct = "image/gif";
        WARCRecordInfo recinfo = TestWARCRecordInfo.createHttpResponse(ct, TestWARCRecordInfo.PAYLOAD_GIF);
        TestWARCReader ar = new TestWARCReader(recinfo);
        WARCRecord rec = ar.get(0);
        Resource payloadResource = new WarcResource(rec, ar);
        payloadResource.parseHeaders();
        Resource headersResource = payloadResource;
View Full Code Here

     *
     * @throws Exception
     */
    public void testRenderResource_CompressedCapture() throws Exception {
        final String ct = "image/gif";
        WARCRecordInfo recinfo = new TestWARCRecordInfo(
                TestWARCRecordInfo.buildCompressedHttpResponseBlock(ct,
                        TestWARCRecordInfo.PAYLOAD_GIF));
        TestWARCReader ar = new TestWARCReader(recinfo);
        WARCRecord rec = ar.get(0);
        Resource payloadResource = new WarcResource(rec, ar);
View Full Code Here

        assertTrue("servlet output", Arrays.equals(TestWARCRecordInfo.PAYLOAD_GIF, content));
    }   
       
    public void testRenderResource_Redirect() throws Exception {
        String location = "http://www.example.com/index.html";
        WARCRecordInfo recinfo = new TestWARCRecordInfo(TestWARCRecordInfo.buildHttpRedirectResponseBlock(location));
        TestWARCReader ar = new TestWARCReader(recinfo);
        WARCRecord rec = ar.get(0);
        Resource payloadResource = new WarcResource(rec, ar);
        payloadResource.parseHeaders();
       
View Full Code Here

            "  <inside/>\n" +
            "</payload>\n";
        final byte[] recordBytes = TestWARCRecordInfo.buildHttpResponseBlock(
            "200 OK", ct, payload.getBytes("UTF-8"), true);
        //System.out.println(new String(recordBytes, "UTF-8"));
        WARCRecordInfo recinfo = new TestWARCRecordInfo(recordBytes);
        TestWARCReader ar = new TestWARCReader(recinfo);
        WARCRecord rec = ar.get(0);
        Resource payloadResource = new WarcResource(rec, ar);
        payloadResource.parseHeaders();
        Resource headersResource = payloadResource;
View Full Code Here

TOP

Related Classes of org.archive.io.warc.WARCRecordInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.