View Javadoc
1 /* Reattore HTTP Server 2 3 Copyright (C) 2002 Michael Hope <michaelh@juju.net.nz> 4 5 This program is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation; either version 2 of the License, or 8 (at your option) any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program; if not, write to the Free Software 17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 19 $Id: HttpParserHelper.java,v 1.9 2003/02/18 04:11:48 michaelh Exp $ 20 */ 21 22 package juju.reattore.protocol.http.impl; 23 24 import java.util.List; 25 import java.io.IOException; 26 27 import juju.reattore.protocol.http.*; 28 import juju.reattore.io.impl.ByteSourceSink; 29 30 /*** Testing interface that wraps the impl parser and request/response. 31 */ 32 public class HttpParserHelper { 33 /*** Create a new parser. 34 35 @return A parser instance. 36 */ 37 public static HttpParser create() { 38 return new BasicHttpParser(); 39 } 40 41 /*** Parse the given string and return it as a request. 42 43 @param in HTTP request string to parse 44 @return The parsed request. 45 @throws ParseException if an error occurs while parsing. 46 @throws IOException on error. 47 */ 48 public static HttpRequest parseRequest(String in) 49 throws ParseException, IOException { 50 51 HttpParser parser = create(); 52 List parsed = parser.add(new ByteSourceSink(in.getBytes())); 53 54 return (HttpRequest)parsed.get(0); 55 } 56 }

This page was automatically generated by Maven