cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Carsten Ziegeler" <cziege...@sundn.de>
Subject AW: Bug 4124 StreamGenerator does not preserve XML encoding PI
Date Mon, 15 Oct 2001 07:44:38 GMT
Hi Kinga,


Kinga Dziembowski wrote:

> Carsten,
> 1. I did fix the problem reported as Bug 4124. Is it enough to send
> the cvs diff or you want the full file attached? Please let me know.
>
> The fix is in StreamGenerator.java. I like as well to update
PostInputStream.java (util).
Great!
A diff is fine. Just send in two diffs one for each file.

>
> 2. Speaking about StreamGenerator, few days ago somebody complained
> about StreamGenerator not processing data from input stream.
> I noticed that it is a difference between my original submitted file and
the current version.
Yes, I patched the StreamGenerator days ago, but after the release
of 2.0rc1a, because the type cast of the Request object to HttpRequest
does not work, if you use the StreamGenerator inside an included pipeline.
For example:
<map:match pattern="test">
  <map:generate src="cocoon://include"/>
  <map:serialize type="xml"/>
</map:match>
<map:match pattern="include">
  <map:generate type="stream"/>
  <map:serialize type="xml"/>
</map:match>

In this case, the Request object of the objectModel in the included
pipeline is not an HttpRequest object!

>
> My original file contained:
> HttpRequest request = (HttpRequest)
objectModel.get(Constants.REQUEST_OBJECT);
> the version in cvs contains:
> Request request = (Request)objectModel.get(Constants.REQUEST_OBJECT);
> Request  does not define getInputStream() method and this was the reason
for malfunctioning.
>
> Then my proposition is to return to HttpRequest  and the rest will work
without any extra patches.
> Or to not use Cocoon abstractions and consistently use
HttpServletRequest - what I mean
> by this obtain at t he first place line (81) HttpServletRequest  and use
it.
> I really do not like the fact that 1/2 information is taken from Request
and
> second 1/2 from HttpServletRequest it is hard to understand, not clean.
Yes, I agree.

> Below is a code corresponding to above two propositions.
>
>try {
>            HttpRequest request =
(HttpRequest )objectModel.get(Constants.REQUEST_OBJECT);
>            if
(request.getContentType().startsWith("application/x-www-form-urlencoded")) {
>                String sXml = request.getParameter(parameter);
>                inputSource = new InputSource(new StringReader(sXml));
>            } else if (request.getContentType().startsWith("text/plain") ||
>                    request.getContentType().startsWith("text/xml") ||
>                    request.getContentType().startsWith("application/xml"))
{
>                len = request.getContentLength();
>
>                if (len > 0) {
>                    if (request != null) {
>                       PostInputStream anStream = new
PostInputStream(request.getInputStream(), len);
>                        inputSource = new InputSource(anStream);
>                    } else .......
> Or
>
> try {
>            HttpServletRequest request =
(HttpServletRequest)objectModel.get
>   (HttpEnvironment.HTTP_REQUEST_OBJECT);
>            if
(request.getContentType().startsWith("application/x-www-form-urlencoded")) {
>                String sXml = request.getParameter(parameter);
>                inputSource = new InputSource(new StringReader(sXml));
>            } else if (request.getContentType().startsWith("text/plain") ||
>                    request.getContentType().startsWith("text/xml") ||
>                    request.getContentType().startsWith("application/xml"))
{
>                len = request.getContentLength();
>
>                if (len > 0) {
>                    if (request != null) {
>                        PostInputStream anStream = new
PostInputStream(request.getInputStream(), len);
>                        inputSource = new InputSource(anStream);
>                    } else ......
>
> Let me know which way you prefer to go and I will do the change before the
submission.
>
I prefer the second solution, as the first one is not working when
used in internal pipelines (as explained above).
However, I don't like the strikt link to the HttpServlet environment,
because
I could use the StreamGenerator e.g. in the CommandLineEnvironment
and specify the source via a parameter (case:
"application/x-www-form-urlencoded").
In the CLI I never have an HttpServletRequest object and that was
a reason for first using only the Request object (which is always
available) and only if required switching to the HttpServletRequest
object.
Perhaps it doesn't make so much sense using the StreamGenerator
in the CLI, so your second solution seems alright. Adding a test,
if the HttpServletRequest object is available and then throwing
a meaningfull exception might be sufficient.

Many thanks for your help,
Carsten

> Take care,
> Kinga
>
> PS. I could not connect today to
http://xml.apache.org/cocoon2/mail-archives.html.
> I was using the link from Mail Archives page.
> ==========================
> Kinga Dziembowski
> KingaDziembowska@msn.com
> Tel:(610) 543-5504
> Fax:(610) 543-6042


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Mime
View raw message