Servlet::ServletInputStream - servlet input stream interface
my $byte = $stream->read(); my $numbytes = $stream->read(\$buffer); my $numbytes = $stream->read(\$buffer, $offset, $length); my $numbytes = $stream->readLine(\$buffer, $offset, $length); $stream->skip($numbytes); if ($stream->markSupported()) { $stream->mark($limit); $stream->reset(); } $stream->close();
Provides an input stream for reading binary data from a client request. With some protocols, such as HTTP POST and PUT, the stream can be used to read data sent from the client.
An input stream object is normally retrieved via "getInputStream" in Servlet::ServletRequest.
NOTE: While this is an abstract class in the Java API, the Perl API provides it as an interface. The main difference is that the Perl version has no constructor. Also, it merges the methods declared in java.io.InputStream and javax.servlet.ServletInputStream into a single interface.
Closes the stream and releases any system resources associated with the stream.
Throws:
if an input exception occurs
Marks the current position in the stream. A subsequent call to reset() repositions the stream at the last marked position so that subsequent reads re-read the same bytes.
reset()
The $limit argument tells the stream to allow that many bytes to be read before the mark position is invalidated. If more than $limit bytes are read, a call to reset() will have no effect.
Parameters:
the maximum number of bytest hat can be read before the marked position becomes invalid
if marking is not supported
Returns true if the stream supports mark() and reset(), or false if it does not.
mark()
If no arguments are specified, returns the next byte of data from the stream, or undef if no byte is available because the end of the stream has been reached.
If arguments are specified, reads up to $length bytes from the stream, stores them in $buffer, and returns the number of bytes read (or undef if no bytes are available because the end of the stream has been reached).
If $offset is specified, the read data is placed $offset bytes from the beginning of $buffer. If $offset is negative, it will be counted backwardsd from the end of the string. If $offset is positive and greater than the length of $buffer, the scalar will be padded to the required size with "\0" bytes before the result of the read is appended.
Blocks until input data is available, the end of the stream is detected, or an exception is thrown.
a reference to a scalar buffer into which the data is read
the maximum number of bytes to read
the location in $buffer where data is written
if $buffer is specified as undef
Reads the input stream one line at a time. Starting at an offset, reads bytes into the buffer until it reads a certain number of bytes or reaches a newline character, which it reads into the array as well. Returns the number of bytes read, or -1 if it reaches the end of the input stream before reading the maximum number of bytes.
a reference to a scalar into which data is read
an integer specifying the byte at which the method begins reading
an integer specifying the maximum number of bytes to read
Repositions the stream to the position at the time mark() was last called on the stream.
if the stream has not been marked, the mark has been invalidated, or marking is not supported
Skips over and discards $num bytes of data from the stream and returns the number of bytes skipped, or -1 if no bytes were skipped.
the number of bytes to skip
Servlet::ServletRequest, Servlet::Util::Exception
Brian Moseley, bcm@maz.org
To install Servlet, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Servlet
CPAN shell
perl -MCPAN -e shell install Servlet
For more information on module installation, please visit the detailed CPAN module installation guide.