Examples of MimeConfig


Examples of org.apache.james.mime4j.stream.MimeConfig

    }

    public Message parseMessage(final InputStream is) throws IOException, MimeIOException {
        try {
            MessageImpl message = new MessageImpl();
            MimeConfig cfg = config != null ? config : new MimeConfig();
            boolean strict = cfg.isStrictParsing();
            DecodeMonitor mon = monitor != null ? monitor :
                strict ? DecodeMonitor.STRICT : DecodeMonitor.SILENT;
            BodyDescriptorBuilder bdb = bodyDescBuilder != null ? bodyDescBuilder :
                new DefaultBodyDescriptorBuilder(null, fieldParser != null ? fieldParser :
                    strict ? DefaultFieldParser.getParser() : LenientFieldParser.getParser(), mon);
View Full Code Here

Examples of org.apache.james.mime4j.stream.MimeConfig

    MimeTokenStream parser;

    @Override
    protected void setUp() throws Exception {
        super.setUp();
        MimeConfig config = new MimeConfig();
        config.setStrictParsing(true);
        parser = new MimeTokenStream(config, new DefaultBodyDescriptorBuilder(null));
    }
View Full Code Here

Examples of org.apache.james.mime4j.stream.MimeConfig

        this.url = url;
    }

    @Override
    protected void runTest() throws Throwable {
        MimeConfig config = new MimeConfig();
        if (getName().startsWith("malformedHeaderStartsBody")) {
            config.setMalformedHeaderStartsBody(true);
        }
        config.setMaxLineLen(-1);
        DefaultMessageBuilder builder = new DefaultMessageBuilder();
        DefaultMessageWriter writer = new DefaultMessageWriter();
        builder.setMimeEntityConfig(config);
        Message inputMessage = builder.parseMessage(url.openStream());
        ByteArrayOutputStream out = new ByteArrayOutputStream();
View Full Code Here

Examples of org.apache.james.mime4j.stream.MimeConfig

    }

    @Override
    protected void runTest() throws IOException {
        MimeConfig config = new MimeConfig();
        if (getName().startsWith("malformedHeaderStartsBody")) {
            config.setMalformedHeaderStartsBody(true);
        }
        config.setMaxLineLen(-1);
        DefaultMessageBuilder builder = new DefaultMessageBuilder();
        builder.setMimeEntityConfig(config);
        Message m = builder.parseMessage(url.openStream());

        String s = url.toString();
View Full Code Here

Examples of org.apache.james.mime4j.stream.MimeConfig

                + "This is a simple message with no CRLFCELF between headers and body.\r\n"
                + "ThisIsNotAnHeader: because this should be already in the body\r\n"
                + "\r\n"
                + "Instead this should be better parsed as a text/plain body\r\n";

        MimeConfig config = new MimeConfig();
        config.setMalformedHeaderStartsBody(true);
        DefaultMessageBuilder builder = new DefaultMessageBuilder();
        builder.setMimeEntityConfig(config);
        Message message = builder.parseMessage(
                new ByteArrayInputStream(headlessContent.getBytes("UTF-8")));
        assertEquals("text/plain", message.getMimeType());
View Full Code Here

Examples of org.apache.james.mime4j.stream.MimeConfig

                + "This is a simple message with no headers. While mime messages should start with\r\n"
                + "header: headervalue\r\n"
                + "\r\n"
                + "Instead this should be better parsed as a text/plain body\r\n";

        MimeConfig config = new MimeConfig();
        config.setMalformedHeaderStartsBody(true);
        DefaultMessageBuilder builder = new DefaultMessageBuilder();
        builder.setMimeEntityConfig(config);
        Message message = builder.parseMessage(
                new ByteArrayInputStream(headlessContent.getBytes("UTF-8")));
        assertEquals("text/plain", message.getMimeType());
View Full Code Here

Examples of org.apache.james.mime4j.stream.MimeConfig

                + "--foo\r\n"
                + "Content-Disposition: form-data; name=\"field03\"; filename=\"mypic.jpg\"\r\n"
                + "Content-Type: image/jpeg\r\n" + "\r\n"
                + "all kind of stuff\r\n" + "--foo--\r\n";

        MimeConfig config = new MimeConfig();
        config.setHeadlessParsing(contentType);
        DefaultMessageBuilder builder = new DefaultMessageBuilder();
        builder.setMimeEntityConfig(config);

        Message message = builder.parseMessage(
                new ByteArrayInputStream(headlessContent.getBytes("UTF-8")));
View Full Code Here

Examples of org.apache.james.mime4j.stream.MimeConfig

       
        this.message = mImpl;
    }

    private MessageServiceFactory newMessageBuilder() throws MimeException {
        MimeConfig mec = new MimeConfig();
        mec.setMaxLineLen(10000);
        mec.setMaxHeaderLen(30000);
       
        MessageServiceFactory mbf = MessageServiceFactory.newInstance();
        mbf.setAttribute("MimeEntityConfig", mec);
        mbf.setAttribute("FlatMode", true);
        mbf.setAttribute("ContentDecoding", false);
View Full Code Here

Examples of org.apache.james.mime4j.stream.MimeConfig

                    new ByteArrayInputStream(data), handler, metadata, context);
            fail();
        } catch (TikaException expected) {
        }

        MimeConfig config = new MimeConfig();
        config.setMaxHeaderLen(-1);
        config.setMaxLineLen(-1);
        context.set(MimeConfig.class, config);
        parser.parse(
                new ByteArrayInputStream(data), handler, metadata, context);
        assertEquals(name.trim(), metadata.get(Metadata.AUTHOR));
    }
View Full Code Here

Examples of org.apache.james.mime4j.stream.MimeConfig

    public void parse(InputStream stream, ContentHandler handler,
            Metadata metadata, ParseContext context) throws IOException,
            SAXException, TikaException {
        // Get the mime4j configuration, or use a default one
        MimeConfig config = new MimeConfig();
        config.setMaxLineLen(10000); // max length of any individual header
        config = context.get(MimeConfig.class, config);

        MimeStreamParser parser = new MimeStreamParser(config);
        XHTMLContentHandler xhtml = new XHTMLContentHandler(handler, metadata);

        MailContentHandler mch = new MailContentHandler(
                xhtml, metadata, config.isStrictParsing());
        parser.setContentHandler(mch);
        parser.setContentDecoding(true);
        TaggedInputStream tagged = TaggedInputStream.get(stream);
        try {
            parser.parse(tagged);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.