cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <mler...@editronics-edu.fr>
Subject Re: Possible bug : problem getting request parameters while uploading a file
Date Wed, 12 Mar 2003 17:25:57 GMT
Actually, not much things have changed.
The CVS repositery has recently changed, so all the file versions are
set to 1.1. But I've got the sources of cocoon 2.0.3 and cocoon 2.0.4.
Therefore I can give you the diffs of some files.



org.apache.cocoon.components.request.MultiPartRequestFactoryImpl
org.apache.cocoon.components.request.multipart.MultiPartRequestWrapper
-> only commentaries are different


diff
cocoon-2.0.3/src/java/org/apache/cocoon/components/request/RequestFactory.java
cocoon-2.0.4/src/java/org/apache/cocoon/components/request/RequestFactory.java
 63c63
<  * @version CVS $Id: RequestFactory.java,v 1.1 2002/02/24 11:10:58
dims Exp $ ---
>  * @version CVS $Id: RequestFactory.java,v 1.1.2.1 2002/10/29 04:48:58
> vgritsenko Exp $
65,66c65
< public abstract class   RequestFactory
<         implements Component {
---
> public abstract class RequestFactory implements Component {
68,72c67,68
<     static private RequestFactory factory;
<
<     public static synchronized RequestFactory getRequestFactory(String
className) { <         if(factory != null)
<             return factory;
---
>     public static RequestFactory getRequestFactory(String className) {
>         RequestFactory factory = null;
77c73,75
<         } catch (Throwable t){}
---
>         } catch (Throwable t) {
>             // FIXME (VG): Is it Ok to ignore all exceptions?
>         }
82c80,82
<             } catch (Throwable t){}
---
>             } catch (Throwable t) {
>                 // FIXME (VG): Is it Ok to ignore all exceptions?
>             }
84c84
<         if(factory == null)
---
>         if (factory == null) {
85a86
>         }
97a99
>
102c104
< }
\ No newline at end of file
---
> }


diff
cocoon-2.0.3/src/java/org/apache/cocoon/components/request/multipart/MultipartParser.java
cocoon-2.0.4/src/java/org/apache/cocoon/components/request/multipart/MultipartParser.java
 75c75
<  * @version CVS $Id: MultipartParser.java,v 1.1.2.2 2002/05/23
12:01:46 froehlich Exp $ ---
>  * @version CVS $Id: MultipartParser.java,v 1.1.2.3 2002/09/21
> 16:29:32 vgritsenko Exp $
182d181
<
184d182
<
187,195c185,193
< 		if (!"".equals(headers.get("filename"))) {
<                 	parseFilePart(ts, headers);
< 		} else {
< 			// IE6 sends an empty part with filename="" for
< 			// empty upload fields. Just parse away the part
< 			byte[] buf = new byte[32];
< 			while(ts.getState() == TokenStream.STATE_READING)
< 				ts.read(buf);
< 		}
---
>                 if (!"".equals(headers.get("filename"))) {
>                     parseFilePart(ts, headers);
>                 } else {
>                     // IE6 sends an empty part with filename="" for //
> empty upload fields. Just parse away the part
> byte[] buf = new byte[32];
>                     while(ts.getState() == TokenStream.STATE_READING)
>                         ts.read(buf);
>                 }
236,239c234,238
<             String filePath = uploadDirectory.getPath() +
File.separator; <
<             String fileName =
<                     new File((String)
headers.get("filename")).getName(); ---
>             String fileName = (String) headers.get("filename");
>             if(File.separatorChar == '\\')
>                 fileName = fileName.replace('/','\\');
>             else
>                 fileName = fileName.replace('\\','/');
240a240,241
>             String filePath = uploadDirectory.getPath() +
> File.separator; fileName = new File(fileName).getName();



diff
cocoon-2.0.3/src/java/org/apache/cocoon/environment/http/HttpRequest.java
cocoon-2.0.4/src/java/org/apache/cocoon/environment/http/HttpRequest.java
 55a56
> import org.apache.avalon.framework.CascadingRuntimeException;
69,70c70,71
<  * @author <a href="mailto:giacomo@apache,org">Giacomo Pati</a>
<  * @version CVS $Id: HttpRequest.java,v 1.6.2.1 2002/05/24 09:06:54
cziegeler Exp $ ---
>  * @author <a href="mailto:giacomo@apache.org">Giacomo Pati</a>
>  * @version CVS $Id: HttpRequest.java,v 1.6.2.7 2002/12/06 10:33:00
> cziegeler Exp $
73c74
< public class HttpRequest implements Request {
---
> public final class HttpRequest implements Request {
76c77
<     private HttpServletRequest req = null;
---
>     private final HttpServletRequest req;
79c80
<     private HttpEnvironment env = null;
---
>     private final HttpEnvironment env;
82c83
<     private String form_encoding = null;
---
>     private String form_encoding;
85c86,89
<     private String container_encoding = null;
---
>     private String container_encoding;
>
>     /** The current session */
>     private HttpSession session;
86a91,93
>     private final RequestFactory requestFactory;
>
>
88c95
<      * Creates a HttpServletRequest based on a real HttpServletRequest
object ---
>      * Creates a HttpRequest based on a real HttpServletRequest object
90,91c97,98
<     protected HttpRequest (HttpServletRequest req, HttpEnvironment
env) { <         super ();
---
>     protected HttpRequest(HttpServletRequest req, HttpEnvironment env,
> RequestFactory requestFactory) {
>         super();
93a101
>         this.requestFactory = requestFactory;
99c107
<         return RequestFactory.getRequestFactory(null).get(this.req,
name); ---
>         return requestFactory.get(this.req, name);
219,222c227,242
<         javax.servlet.http.HttpSession session =
this.req.getSession(create); <         if(session != null)
<             return new HttpSession(session);
<         return null;
---
>         javax.servlet.http.HttpSession serverSession =
> this.req.getSession(create); if ( null != serverSession) {
>             if ( null != this.session ) {
>                 if ( this.session.wrappedSession != serverSession ) {
>                     // update wrapper
>                     this.session.wrappedSession = serverSession;
>                 }
>             } else {
>                 // new wrapper
>                 this.session = new HttpSession( serverSession );
>             }
>         } else {
>             // invalidate
>             this.session = null;
>         }
>         return this.session;
296a317
>         if (str == null) return null;
303,304c324
<             throw new RuntimeException("Unsupported Encoding
Exception: " + <             uee.getMessage());
---
>             throw new CascadingRuntimeException("Unsupported Encoding
> Exception", uee);
313a334
>         if (values == null) return null;


diff
cocoon-2.0.3/src/java/org/apache/cocoon/environment/http/HttpEnvironment.java
cocoon-2.0.4/src/java/org/apache/cocoon/environment/http/HttpEnvironment.java
 53a54
> import org.apache.cocoon.components.request.RequestFactory;
71c72
<  * @version CVS $Id: HttpEnvironment.java,v 1.12 2002/03/27 15:13:40
sylvain Exp $ ---
>  * @version CVS $Id: HttpEnvironment.java,v 1.12.2.3 2002/10/29
> 04:48:59 vgritsenko Exp $
108c109,110
<                             String defaultFormEncoding)
---
>                             String defaultFormEncoding,
>                             RequestFactory requestFactory)
112c114
<         this.request = new HttpRequest (req, this);
---
>         this.request = new HttpRequest(req, this, requestFactory);
115c117
<         this.response = new HttpResponse (res);
---
>         this.response = new HttpResponse(res);
246c248
<      * @result true if the response is modified or if the
---
>      * @return true if the response is modified or if the
249a252,255
>         // workaround for bug #12915
>         // FIXME
>         return true;
>         /*
253a260
>         */





> Very interesting - I didn't think much changed with the parser
> itself.  What does cvs  show? (can't and shouldn't access it from
> work)
>
> Geoff
>
> At 09:07 AM 3/12/2003, you wrote:
>
>
>>Well, I already knew these configuration details.
>>Here 's my configuration :
>>autosave-uploads = true
>>upload-directory = /WEB-INF/work/upload-dir
>>overwrite-uploads = rename
>>upload-max-size = 10000000
>>request-factory =
>>org.apache.cocoon.components.request.MultipartRequestFactoryImpl
>>
>>I can precise that the directory upload-dir is not created at cocoon
>> initialization (it was done with cocoon 2.0.3).
>>
>>I think the problem comes from the request parsing or near this,
>> because I've put some log outputs in the RequestParamAction that
>> shows this : 14:58:46,184 DEBUG [RequestParamAction] map =
>> {requestQuery=,
>>context=/icartable, requestURI=/icartable/educ/teacherWork/51.html}
>>
>>instead of:
>>14:58:46,184 DEBUG [RequestParamAction] map = {requestQuery=,
>>context=/icartable, requestURI=/icartable/educ/teacherWork/51.html,
>> actiontype=main, file=file.txt}
>>
>>(or
>> file=org.apache.cocoon.components.request.multipart.FilePartFile@321565)
>>
>>It looks as if the parser hasn't done its work correctly in this
>> particular case.
>>
>>
>>     Michael
>>
>>
>>
>> > There were some changes between 2.0.3 and 2.0.4 WRT file uploads.
>> The one that pops out immediately without knowing much about your
>> action is that autosaving file uploads is now set to false by
>> default in web.xml. This means that you'll have a FilePartArray in
>> the request.  If you weren't aware of that, can you try to modify
>> web.xml and see if that "fixes" it?
>> >
>> > Geoff Howard
>> >
>> > At 05:36 AM 3/12/2003, you wrote:
>> >
>> >>       Hi !
>> >>
>> >>
>> >>I've recently upgraded from Cocoon 2.0.3 to Cocoon 2.0.4 and
>> something
>> >> doesn't work anymore.
>> >>I've posted a message on cocoon-users but no one seems to be able
>> to
>> >> answer me.
>> >>
>> >>Here's a summary of the problem :
>> >>I need to upload a file from an HTML form. I use the automatic
>> upload
>> >> provided by cocoon and the RequestParamAction to pass some
>> parameters to my personal upload action.
>> >>With cocoon 2.0.3, it works as I need.
>> >>With cocoon 2.0.4, the behavior changes when method="GET" or
>> "POST",
>> >> and when the FILE input is filled or not ... really strange ...
>> >>
>> >>
>> >>     Michael
>> >>
>> >>
>> >>----------------------------------------------------------------------
>> >> Here are the messages I sent to the cocoon-users list. They give
>> more details.
>> >>
>> >>
>> >>     Hi !
>> >>
>> >>I've recently upgraded to Cocoon 2.0.4 and something doesn't work
>> >> anymore : I now can't get a parameter value in the sitemap with
>> the
>> RequestParamAction and the POST method.
>> >>
>> >>
>> >>Here's my configuration :
>> >>Cocoon 2.0.4, JDK 1.3, Jetty, Jboss
>> >>MultipartRequestFactoryImpl (defined in a web.xml file)
>> >>
>> >>
>> >>Here's the way I use it :
>> >>I want to get a parameter named 'actiontype' and defined in a form
>> and
>> >> I want to pass its value through the sitemap to an action.
>> >>
>> >>I've got a sitemap.xmap file :
>> >><!-- T e a c h e r W o r k
>> >>{1} teacher work Id
>> >>-->
>> >><map:match pattern="teacherWork/*.html">
>> >>   <map:act type="request">
>> >>     <map:parameter name="parameters" value="true"/>
>> >>       <map:act type="upload">
>> >>         <!-- This parameter determines the action -->
>> >>         <map:parameter name="actiontype" value="{actiontype}"/>
>> >>...
>> >>
>> >>
>> >>And I've got an HTML form (this page is dynamicly generated, here's
>> an
>> >> instance) :  <form enctype="multipart/form-data" method="post"
>> >>action="teacherWork/18.html">
>> >>   <input type="hidden" name="actiontype" value="main"/>
>> >>   <input type="file" name="filename"/>
>> >>...
>> >>
>> >>
>> >>And I've got a cocoon action of my own with a logger showing me the
>> >> value of the parameter named 'actiontype'.
>> >>
>> >>
>> >>With cocoon 2.0.3, everything works fine.
>> >>With cocoon 2.0.4 : when method="post" the logs say actiontype = ''
>> >> when method="get" the logs say actiontype = 'main' Everything
>> would
>> be alright in the best world if i didn't need to use the POST
>> method (in order to have a FilePartFile object in the request).
>> >>
>> >>I'm sure the only difference is the version of cocoon that I'm
>> using
>> >> although there's still the possibility that I forgot some other
>> change of mine.
>> >>
>> >>
>> >>
>> >>Would anybody help me ?
>> >>
>> >>
>> >>      Michael
>> >>----------------------------------------------------------------------
>> >>
>> >>     Hi !
>> >>
>> >>
>> >>I've recently posted an issue, and I've got new elements.
>> >>My problem is :
>> >>I can't pass a request parameter through the sitemap when I put a
>> file
>> >> path in an HTML FILE input and send it as POST multipart/form-data
>> to a Cocoon 2.0.4 servlet.
>> >>
>> >>When I don't try to upload any file, I can pass the parameter
>> value.
>> >> When I try to upload a file, I can't get the parameter value
>> anymore. Actually, it's as if there are no parameters in the
>> request.
>> >>
>> >>
>> >>Can somebody tell me if he can reproduce this problem on his
>> >> environment ?
>> >>
>> >>
>> >>      Michael.




Mime
View raw message