cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "kingadziembowska" <kingadziembow...@msn.com>
Subject Bug 4124 StreamGenerator does not preserve XML encoding PI
Date Mon, 15 Oct 2001 02:48:20 GMT
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).

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.

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 the 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.
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.

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

Mime
View raw message