gnu.inet.http

Class ByteArrayRequestBodyWriter

Implemented Interfaces:
RequestBodyWriter

public class ByteArrayRequestBodyWriter
extends java.lang.Object
implements RequestBodyWriter

A simple request body writer using a byte array.

Author:
Chris Burdess

Nested Class Summary

Field Summary

protected byte[]
content
The content.
protected int
pos
The position within the content at which the next read will occur.

Constructor Summary

ByteArrayRequestBodyWriter(byte[] content)
Constructs a new byte array request body writer with the specified content.

Method Summary

int
getContentLength()
Returns the total number of bytes that will be written in a single pass by this writer.
void
reset()
Initialises the writer.
int
write(byte[] buffer)
Writes body content to the supplied buffer.

Field Details

content

protected byte[] content
The content.


pos

protected int pos
The position within the content at which the next read will occur.

Constructor Details

ByteArrayRequestBodyWriter

public ByteArrayRequestBodyWriter(byte[] content)
Constructs a new byte array request body writer with the specified content.

Parameters:
content - the content buffer

Method Details

getContentLength

public int getContentLength()
Returns the total number of bytes that will be written in a single pass by this writer.
Specified by:
getContentLength in interface RequestBodyWriter


reset

public void reset()
Initialises the writer. This will be called before each pass.
Specified by:
reset in interface RequestBodyWriter


write

public int write(byte[] buffer)
Writes body content to the supplied buffer.
Specified by:
write in interface RequestBodyWriter

Parameters:
buffer - the content buffer

Returns:
the number of bytes written


© Copyright 2003 The Free Software Foundation, all rights reserved