FileDocCategorySizeDatePackage
Request.javaAPI DocSun JDK 1.5.0 Example4856Sat Jan 08 15:08:43 GMT 2005None

Request

public class Request extends Object
An encapsulation of the request received.

The static method parse() is responsible for creating this object.

author
Mark Reinhold
author
Brad R. Wetmore
version
1.2, 04/07/26

Fields Summary
private Action
action
private String
version
private URI
uri
private static Charset
ascii
private static Pattern
requestPattern
Constructors Summary
private Request(Action a, String v, URI u)

	action = a;
	version = v;
	uri = u;
    
Methods Summary
Request$Actionaction()

 return action; 
static booleanisComplete(java.nio.ByteBuffer bb)

	int p = bb.position() - 4;
	if (p < 0)
	    return false;
	return (((bb.get(p + 0) == '\r") &&
		 (bb.get(p + 1) == '\n") &&
		 (bb.get(p + 2) == '\r") &&
		 (bb.get(p + 3) == '\n")));
    
static Requestparse(java.nio.ByteBuffer bb)


          

	CharBuffer cb = ascii.decode(bb);
	Matcher m = requestPattern.matcher(cb);
	if (!m.matches())
	    throw new MalformedRequestException();
	Action a;
	try {
	    a = Action.parse(m.group(1));
	} catch (IllegalArgumentException x) {
	    throw new MalformedRequestException();
	}
	URI u;
	try {
	    u = new URI("http://"
			+ m.group(4)
			+ m.group(2));
	} catch (URISyntaxException x) {
	    throw new MalformedRequestException();
	}
	return new Request(a, m.group(3), u);
    
public java.lang.StringtoString()

	return (action + " " + version + " " + uri);
    
java.net.URIuri()

 return uri; 
java.lang.Stringversion()

 return version;