java.lang.Object
raining.protocol.http.HttpOKResponse
- All Implemented Interfaces:
- raining.core.Response
- public class HttpOKResponse
- extends java.lang.Object
- implements raining.core.Response
Interface for Response, including response header creation.
TODO:Remember that headers need to cached as does data.
I suggest if not found in cache, we can store these contents using
getContent. Else we just send the content as a whole without coming
here.
What about when file is updated. We need the header to be generated.
Acco to RFC 2616 a server SHOULD send a "Date:" header, with the
closest approximation of the time. THis means we have to keep
updating this header and store it separately. However, the RFC states
that if we cant give an accurate time, then we SHOULD not. XXX
XXX i have begun passing in the request object, for logging etc.
However, when the cacher precreates a header, or updates it there
wont be a request. so logging cant really happen here.
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
header
static byte[] header
sheader
static java.lang.String sheader
HTTP_VERSION
public static final java.lang.String HTTP_VERSION
- See Also:
- Constant Field Values
CRLF
public static final java.lang.String CRLF
- See Also:
- Constant Field Values
CRLF2
public static final java.lang.String CRLF2
- See Also:
- Constant Field Values
contentType
public static final java.lang.String contentType
- See Also:
- Constant Field Values
LAST_MODIFIED_HEADER_SIZE
public static final int LAST_MODIFIED_HEADER_SIZE
LAST_MODIFIED
public static final byte[] LAST_MODIFIED
DATE_SIZE
public static final int DATE_SIZE
- See Also:
- Constant Field Values
content
byte[] content
sb
java.lang.StringBuffer sb
P
public static final java.lang.String P
- See Also:
- Constant Field Values
HttpOKResponse
public HttpOKResponse(raining.core.Request request,
byte[] incoming,
long fileupdatetime)
- constructor taking a byte array. This would be the preferred
constructor.
next line takes 263ms for 100,000 iterations
byte[] blen = new byte[]{(byte)'1',(byte)'6'};
next line takes 1020ms for 100,000 iterations
byte[] blen = (Integer.toString(incoming.length)).getBytes();
next line takes 285ms for 100,000 iterations
byte[] blen = int2byte (incoming.length);
HttpOKResponse
public HttpOKResponse(raining.core.Request request,
java.lang.String incoming)
getBytes
public byte[] getBytes()
- return as a stream of bytes.
preferred since we can use bytes
throughout and avoid costly string to byte conversions.
- Specified by:
getBytes in interface raining.core.Response
getString
public java.lang.String getString()
- return content as a String.
to start with we use this. this does a conversion 3 times, so
avoid.
- Specified by:
getString in interface raining.core.Response
main
public static void main(java.lang.String[] args)