com.quadrique.jbuildingblocks.core.io.socket.server
Class JbbHttpRequest

java.lang.Object
  extended by com.quadrique.jbuildingblocks.core.io.socket.server.JbbHttpRequest

public class JbbHttpRequest
extends Object

This class is used to manipulate a HTTP request. It is typically used in two ways: - to build an HTTP Request from scratch (with the goal to send it over a socket connection...) - extract an incoming HTTP request from a socket connection (with the goal to access the individual request fields)

Version:
1.0.0
Author:
Hervé Rivere

Constructor Summary
JbbHttpRequest()
          Constructor
 
Method Summary
 void extractIncomingHttpRequestInformation(BufferedInputStream zInputStream)
          build the instance from the given socket input stream
 byte[] getBody()
           
 String getBodyAsString()
           
 int getContentLength()
           
 String getContentType()
           
 String getHeaderFieldValue(String zHeaderFieldName)
           
 String getHeaderFieldValues(boolean zIsHtml)
           
 String getHost()
           
 String getMethod()
           
 int getNbOfHeaderFields()
           
 int getNbOfQueryParameters()
           
 String getQueryParameterValue(String zQueryParameterName)
           
 String getQueryParameterValues(boolean zIsHtml)
           
 String getQueryString()
           
 String getResource()
           
 String getUri()
           
 String getUserAgent()
           
 String getVersion()
           
static String guessContentTypeFromName(String name)
           
 boolean is10()
           
 boolean is11()
           
 boolean isGet()
           
 boolean isPost()
           
 void validate()
          This method is typically called once a request has been built (either from scratch or from an incoming request on a socket connection) to make sure that the HTTP request is valid
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JbbHttpRequest

public JbbHttpRequest()
Constructor

Method Detail

extractIncomingHttpRequestInformation

public void extractIncomingHttpRequestInformation(BufferedInputStream zInputStream)
                                           throws Exception
build the instance from the given socket input stream

Throws:
Exception

validate

public void validate()
              throws Exception
This method is typically called once a request has been built (either from scratch or from an incoming request on a socket connection) to make sure that the HTTP request is valid

Throws:
Exception - if the request is not valid

getMethod

public String getMethod()

isGet

public boolean isGet()

isPost

public boolean isPost()

getVersion

public String getVersion()

is10

public boolean is10()

is11

public boolean is11()

getUri

public String getUri()
Returns:
the full URI from the HTTP request (e.g. "/.../.../...?key1=value1&key2=value2&key3=value3")

getResource

public String getResource()
Returns:
the resource from the HTTP request. For intance, if the URI is of the form "/.../.../...?key1=value1&key2=value2&key3=value3", getResource() will return "/.../.../..."

getQueryString

public String getQueryString()
Returns:
the query string from the HTTP request. For intance, if the URI is of the form "/.../.../...?key1=value1&key2=value2&key3=value3", getQueryString() will return "key1=value1&key2=value2&key3=value3".

getNbOfQueryParameters

public int getNbOfQueryParameters()

getQueryParameterValues

public String getQueryParameterValues(boolean zIsHtml)

getQueryParameterValue

public String getQueryParameterValue(String zQueryParameterName)

getNbOfHeaderFields

public int getNbOfHeaderFields()

getHeaderFieldValues

public String getHeaderFieldValues(boolean zIsHtml)

getHeaderFieldValue

public String getHeaderFieldValue(String zHeaderFieldName)

getUserAgent

public String getUserAgent()

getHost

public String getHost()

getContentType

public String getContentType()

getContentLength

public int getContentLength()
                     throws Exception
Returns:
-1 if content-length filed is not available or not valid
Throws:
Exception

getBody

public byte[] getBody()

getBodyAsString

public String getBodyAsString()
                       throws Exception
Throws:
Exception

guessContentTypeFromName

public static String guessContentTypeFromName(String name)


Copyright © 2001-2008 Quadrique Corporation. All Rights Reserved.