Package juju.reattore.protocol.http.impl

Source Code of juju.reattore.protocol.http.impl.HttpParserHelper

/*  Reattore HTTP Server

    Copyright (C) 2002 Michael Hope <michaelh@juju.net.nz>

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

    $Id: HttpParserHelper.java,v 1.9 2003/02/18 04:11:48 michaelh Exp $
*/

package juju.reattore.protocol.http.impl;

import java.util.List;
import java.io.IOException;

import juju.reattore.protocol.http.*;
import juju.reattore.io.impl.ByteSourceSink;

/** Testing interface that wraps the impl parser and request/response.
*/
public class HttpParserHelper {
    /** Create a new parser.

        @return  A parser instance.
     */
    public static HttpParser create() {
        return new BasicHttpParser();
    }

    /** Parse the given string and return it as a request.

        @param in   HTTP request string to parse
        @return     The parsed request.
        @throws ParseException if an error occurs while parsing.
        @throws IOException on error.
    */
    public static HttpRequest parseRequest(String in)
        throws ParseException, IOException {

        HttpParser parser = create();
        List parsed = parser.add(new ByteSourceSink(in.getBytes()));

        return (HttpRequest)parsed.get(0);
    }
}
TOP

Related Classes of juju.reattore.protocol.http.impl.HttpParserHelper

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.