The StreamGenerator is a class that reads XML from a request
InputStream and generates SAX Events.
For the POST requests with a mimetype of application/x-www-form-urlencoded
or multipart/form-data the xml data is expected to be associated
with the sitemap parameter form-name.
For the POST requests with mimetypes text/plain, text/xml,
application/xhtml+xml, application/xml the xml data
is expected to be in the body of the POST request and its length is specified
by the value returned by Request.getContentLength() method.
The StreamGenerator uses helper PostInputStream class for InputStream
reading operations. At the time when Parser is reading the data out of the
InputStream, Parser has no knowledge about the length of data to be read.
The only way to signal to the Parser that all data was read from the
InputStream is to control reading operation - by the means of
PostInputStream - and to return to the requestor '-1' when the
number of bytes read is equal to the content length value.
getCharacterEncoding(org.apache.cocoon.environment.Request req,
String contentType)
Content type HTTP header can contain character encoding information,
for example: Content-Type: text/xml; charset=UTF-8.
Methods inherited from class org.apache.cocoon.generation.ServiceableGenerator
dispose, service
Methods inherited from class org.apache.cocoon.generation.AbstractGenerator
recycle, setup
Methods inherited from class org.apache.cocoon.xml.AbstractXMLProducer
setConsumer, setContentHandler, setLexicalHandler
Methods inherited from class org.apache.cocoon.util.AbstractLogEnabled
public StringgetCharacterEncoding(org.apache.cocoon.environment.Request req,
String contentType)
Content type HTTP header can contain character encoding information,
for example: Content-Type: text/xml; charset=UTF-8.
If the servlet is following spec 2.3 and higher, the servlet API can
be used to retrieve character encoding part of Content-Type header. Some
containers can choose to not unpack charset info - the spec is not strong
about it. In any case, this method can be used as a last resort to
retrieve the passed charset value.
It is very common mistake to send : Content-Type: text/xml; charset="UTF-8".
Some containers are not filtering this mistake and the processing results in exception.
This method compensates for the above mistake.
If contentType is null or has no charset part, null is returned.
Parameters:
contentType - value associated with Content-Type HTTP header.