php.java.bridge.http
Class HttpRequest

java.lang.Object
  extended by php.java.bridge.http.HttpRequest

public class HttpRequest
extends java.lang.Object

A simple HTTP request implementation.

Author:
jostb

Constructor Summary
HttpRequest(java.io.InputStream inputStream)
          Create a new HTTP request
 
Method Summary
 void addHeader(java.lang.String line)
          Add a header
 void close()
          Close the request
 java.lang.String getHeader(java.lang.String string)
          Returns the header value
 java.io.InputStream getInputStream()
          Returns the InputStream
 java.lang.String getMethod()
          Return the request Method
 java.lang.String getRequestURI()
          Return the request URI
 void pushBack(byte[] buf, int start, int length)
          Push back some bytes so that we can read them again.
 void setContentLength(int contentLength)
          Set the content length, it causes the InputStream to stop reading at some point.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpRequest

public HttpRequest(java.io.InputStream inputStream)
Create a new HTTP request

Parameters:
inputStream - The InputStream
Method Detail

getHeader

public java.lang.String getHeader(java.lang.String string)
Returns the header value

Parameters:
string - The header
Returns:
The header value

getMethod

public java.lang.String getMethod()
Return the request Method

Returns:
GET, PUT or POST

getRequestURI

public java.lang.String getRequestURI()
Return the request URI

Returns:
The request URI

getInputStream

public java.io.InputStream getInputStream()
Returns the InputStream

Returns:
The InputStream

pushBack

public void pushBack(byte[] buf,
                     int start,
                     int length)
Push back some bytes so that we can read them again.

Parameters:
buf - The buffer
start - The start position
length - The number of bytes

addHeader

public void addHeader(java.lang.String line)
Add a header

Parameters:
line - A valid HTTP header, e.g. "Host: localhost"

setContentLength

public void setContentLength(int contentLength)
Set the content length, it causes the InputStream to stop reading at some point.

Parameters:
contentLength - The content length.
See Also:
getInputStream()

close

public void close()
           throws java.io.IOException
Close the request

Throws:
java.io.IOException