You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by gi...@apache.org on 2003/07/27 14:52:50 UTC

cvs commit: cocoon-2.1/src/documentation/xdocs/userdocs/generators stream-generator.xml

gianugo     2003/07/27 05:52:50

  Modified:    src/java/org/apache/cocoon/generation StreamGenerator.java
               src/documentation/xdocs/userdocs/generators
                        stream-generator.xml
  Log:
  Add a defaultContentType parameter to StreamGenerator, to allow interop
  with client (MS...) not setting this field on requests.
  PR: 21881
  Submitted by:	Guido Casper (g.casper@s-und-n.de)
  
  Revision  Changes    Path
  1.2       +9 -3      cocoon-2.1/src/java/org/apache/cocoon/generation/StreamGenerator.java
  
  Index: StreamGenerator.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/generation/StreamGenerator.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- StreamGenerator.java	9 Mar 2003 00:09:31 -0000	1.1
  +++ StreamGenerator.java	27 Jul 2003 12:52:49 -0000	1.2
  @@ -123,7 +123,13 @@
               HttpServletRequest request = (HttpServletRequest) objectModel.get(HttpEnvironment.HTTP_REQUEST_OBJECT);
               contentType = request.getContentType();
               if (contentType == null) {
  -                throw new IOException("Required header ContentType is missing.");
  +                contentType = parameters.getParameter("defaultContentType", null);
  +                if (getLogger().isDebugEnabled()) {
  +                    getLogger().debug("no Content-Type header - using contentType parameter");
  +                }
  +            }
  +            if (contentType == null) {
  +                throw new IOException("both Content-Type header and defaultContentType parameter are not set");
               } else if (contentType.startsWith("application/x-www-form-urlencoded") ||
                       contentType.startsWith("multipart/form-data")) {
                   String parameter = parameters.getParameter(FORM_NAME, null);
  @@ -151,7 +157,7 @@
               }
   
               if (getLogger().isDebugEnabled()) {
  -                getLogger().debug("processing stream ContentType= " + request.getContentType() + "ContentLen= " + len);
  +                getLogger().debug("processing stream ContentType=" + contentType + " ContentLen=" + len);
               }
               String charset =  getCharacterEncoding(request, contentType) ;
               if( charset != null)
  
  
  
  1.2       +17 -5     cocoon-2.1/src/documentation/xdocs/userdocs/generators/stream-generator.xml
  
  Index: stream-generator.xml
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/documentation/xdocs/userdocs/generators/stream-generator.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- stream-generator.xml	9 Mar 2003 00:08:19 -0000	1.1
  +++ stream-generator.xml	27 Jul 2003 12:52:49 -0000	1.2
  @@ -17,7 +17,7 @@
   	            <p>
         	      The StreamGenerator is a class that reads XML from an HttpRequest 
               	InputStream and generates SAX Events. StreamGenerator expects 
  -	            XML data coming as POST message. 
  +	            XML data coming as HTTP request message. 
         	      </p>
   			<ul>
   				<li>Name : stream</li>
  @@ -31,8 +31,8 @@
   	            </p>
   
         	      <p>
  -            	For POST requests with mimetypes: text/plain, text/xml, application/xml 
  -	            the xml data is in the body of the POST request and its length is 
  +            	For HTTP requests with mimetypes: text/plain, text/xml, application/xml 
  +	            the xml data is in the body of the HTTP request and its length is 
         	      specified by the value returned by getContentLength() method.
               	</p>
   			<s2 title="PostInputStream">
  @@ -50,7 +50,7 @@
   			<s2 title="See it in Action">
   	            <p>
               	The Generator is a generic object, i.e. it can process any stream out of the 
  -      	      POST message there are two ways to see StreamGenerator in action:
  +      	      HTTP message. There are two ways to see StreamGenerator in action:
   	            </p>
               
               	<ul>
  @@ -69,7 +69,7 @@
               
               	<p>
         	      The second or "pure" option of testing StreamGenerator "in action," requires the 
  -	            use of Telnet program or any other process able to generate correct POST message. 
  +	            use of Telnet program or any other process able to generate correct HTTP message. 
               	The procedure is:
         	      </p>
   
  @@ -94,6 +94,18 @@
   <source>
        <![CDATA[
     <map:generate type="stream"/>
  +     ]]>
  +</source>
  +            <p>
  +      	      If you want to process XML streams sent by clients that don't set the Content-Type HTTP header
  +              just use the defaultContentType parameter.
  +                 
  +            </p>
  +<source>
  +     <![CDATA[
  +  <map:generate type="stream">
  +    <map:parameter name="defaultContentType" value="text/xml"/>
  +  </map:generate>
        ]]>
   </source>
           		</s2>