com.ibm.portal.resolver.streams
Class FormDataInputStream
java.lang.Object
java.io.InputStream
com.ibm.portal.resolver.streams.MultipartInputStream
com.ibm.portal.resolver.streams.FormDataInputStream
- All Implemented Interfaces:
- FormDataStream, MultipartStream, java.io.Closeable, java.nio.channels.Channel
-
public abstract class FormDataInputStream
- extends MultipartInputStream
- implements FormDataStream
Input stream that decodes a stream of type "multipart/form-data". This stream
in particular only iterates over those pieces of the input stream with a
Content-Disposition: form-data; The "name" attribute of this content
disposition is available via the FormDataInputStream.Entry.getName() method. The class
also automatically detects the presence of the "_charset_" parameter and uses
it to correctly decode string parameters (see
http://www.whatwg.org/specs/web-forms/current-work/#the-charset). The stream
sequentially iterates over all parameters, and only applies the "_charset_"
parameter to all subsequent parameters. The "_charset_" parameter itself is
not exposed, but the current characterset can be queried via the
FormDataInputStream.Entry.getCharset() method. Use the readString() method to
read the complete parameter in the current characterset into a string
representation. This method is appropriate for small parameter values. Use
the read(Writer) method to process large parameters or wrap the
InputStream into a InputStreamReader.
If this stream in used in conjunction with a DataSink, make sure to protect
potentially harmful operations with a nonce. The nonce should be part of the
stream as the hidden input field "_csrf_token_" and will be available via
FormDataInputStream.Entry.getNonce(). This nonce value can be validated against the nonce
of the current user via the nonce service.
- Since:
- 6.1.0
Methods inherited from class java.io.InputStream
|
available, close, mark, markSupported, read, read, read, reset, skip |
Methods inherited from class java.lang.Object
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.nio.channels.Channel
|
close, isOpen |
CONTENT_TYPE_FORM_DATA
@Deprecated
public static final java.lang.String CONTENT_TYPE_FORM_DATA
- Deprecated. use FormDataStream.CONTENT_TYPE_FORM_DATA instead
- mime type constants
- See Also:
- Constant Field Values
COPYRIGHT
protected static final java.lang.String COPYRIGHT
- copyright statement
- See Also:
- Constant Field Values
KEY_CHARSET
@Deprecated
public static final java.lang.String KEY_CHARSET
- Deprecated. use FormDataStream.KEY_CHARSET instead
- The special key of a form-upload parameter that the browsers set to the
correct characterset
- See Also:
- Constant Field Values
VALUE_FORM_DATA
@Deprecated
public static final java.lang.String VALUE_FORM_DATA
- Deprecated. use FormDataStream.VALUE_FORM_DATA instead
- identification of a content disposition that identifies a form field
- See Also:
- Constant Field Values
FormDataInputStream
public FormDataInputStream()
matches
public static boolean matches(javax.mail.internet.ContentType ct)
- Checks if the mime type is valid for a multipart/form-data input
- Parameters:
- ct - the content type to check, not null
- Returns:
- true if this is a valid content type, else
false
- Since:
- 8.0
getNextEntry
public abstract FormDataInputStream.Entry getNextEntry()
throws java.io.IOException
-
Reads the next multipart stream entry and positions stream at the
beginning of the entry data. Note that FormDataInputStream.Entry instances may be
recycled, the entry is only valid until the next call to
getNextEntry() or MultipartStream.closeEntry().
The implementation will at least interpret the following headers
automatically
- Specified by:
- getNextEntry in class MultipartInputStream
- Returns:
- the form entry just read or null if there is no more
entry
- Throws:
- java.io.IOException - if an I/O error has occurred
read
@Deprecated
public abstract int read(java.io.Writer dst)
throws java.io.IOException
- Deprecated. use FormDataInputStream.Entry.read(Writer) instead
- Reads the value of the field in the current characterset and copies it
into the target writer.
- Parameters:
- dst - target writer, not null
- Returns:
- the number of characters actually copied
- Throws:
- java.io.IOException - - if the data could not be read or copied
readString
@Deprecated
public abstract java.lang.String readString()
throws java.io.IOException
- Deprecated. use FormDataInputStream.Entry.readString() instead
- Reads the value of the field as a string
- Returns:
- the value as a string
- Throws:
- java.io.IOException - if an I/O error has occurred