net.noderunner.http
Class RequestLine

java.lang.Object
  extended by net.noderunner.http.RequestLine

public class RequestLine
extends Object

This is a immutable implementation of an HTTP request line.


Constructor Summary
RequestLine(Method method, String requestURI)
          Constructs using a method, a request URI, and the default HTTP/1.1 version.
RequestLine(Method method, String requestURI, HttpVersion version)
          Constructs using all Request-Line parts.
RequestLine(RequestLine requestLine, String requestURI)
          Copy-constructs a new RequestLine using a different requestURI.
RequestLine(String line)
          Construct using an unparsed request line.
 
Method Summary
static RequestLine create(URL url, Method method)
          Creates and returns a request line based on a URL and method.
 HttpVersion getHttpVersion()
          Returns the version of this request.
 Method getMethod()
          Returns the name of the request method.
 String getRequestURI()
          Returns the URI of this request.
 String toString()
          Returns this RequestLine as:
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RequestLine

public RequestLine(Method method,
                   String requestURI)
Constructs using a method, a request URI, and the default HTTP/1.1 version. If the URI is empty, defaults to the file /.


RequestLine

public RequestLine(Method method,
                   String requestURI,
                   HttpVersion version)
Constructs using all Request-Line parts.


RequestLine

public RequestLine(String line)
            throws HttpException
Construct using an unparsed request line. This string should not end in CRLF.

Throws:
HttpException - if an invalid HTTP Request-Line was used in initialization

RequestLine

public RequestLine(RequestLine requestLine,
                   String requestURI)
Copy-constructs a new RequestLine using a different requestURI.

Parameters:
requestLine - existing request line
fileName - new file name
Method Detail

create

public static RequestLine create(URL url,
                                 Method method)
Creates and returns a request line based on a URL and method. For any method, the line consists of the given method, the filename, and HTTP/1.1 request line. For example, a valid method is the constant RequestLine#METHOD_GET.


getMethod

public Method getMethod()
Returns the name of the request method. This should be either one of the constant string methods in this class, or an extension-method.


getRequestURI

public String getRequestURI()
Returns the URI of this request.


getHttpVersion

public HttpVersion getHttpVersion()
Returns the version of this request.


toString

public String toString()
Returns this RequestLine as:
 getMethod() + ' ' + getRequestURI() + ' ' + getHttpVersion()
 
Note: Does not include CRLF.

Overrides:
toString in class Object


Copyright © 2011. All Rights Reserved.