6 Replies Latest reply on Jan 23, 2015 2:22 AM by horowitzathome

    FileUpload generates large Request Header with Request Parameters

    horowitzathome

      Hello,

      we have the following simple client code:

       

      <rich:fileUpload fileUploadListener="#{someBean.uploadListener}" maxFilesQuantity="10" execute="@none"/>

       

      It seems that all parameters which are defined within this form are passed via the request header, even though for execute “@none” is specified. This increases our Request Header significantly and has in our case more than 5 KB.

       

      Performing any other request like a4j:commandButton does not generate such big Request Headers because such requests do not add all the parameters to the Request Parameters.

       

      The large list of request parameters generates some troubles in one of our systems which is located in front of our server. It seems that it cannot handle these large amount of Request Header data. Does it have any reason why especially with the fileUpload control so many data are sent to the server? If not, how can this behavior been avoided?

       

      We use RichFaces 4.5.2.Final.

       

      Regards,

      Georg

        • 1. Re: FileUpload generates large Request Header with Request Parameters
          michpetrov

          Hi,

           

          you can put the fileupload in a separate form, having one big form for everything may not be ideal. But I don't think I understand the issue, the only things affected are the request URL (which would contain all the input values) and request payload that contains the file that you're uploading and I'd expect that to be bigger than everything else. I don't see anything in request headers that would be affected by the contents of the form.

          1 of 1 people found this helpful
          • 2. Re: FileUpload generates large Request Header with Request Parameters
            horowitzathome

            Yes, I think that’s the point, the request URL gets very large because it contains all the parameters. I am wondering why the fileUpload is doing that resp. why the parameters are necessary in this case. For lets say a commandButton the parameters are not part of the request URL.

             

            Anyways, what I have done already is what you also suggested, to split the input controls in several forms.

            • 3. Re: FileUpload generates large Request Header with Request Parameters
              michpetrov

              That's weird, the long URL is a result of jsf.getViewState() (in jsf.js), which returns all relevant input/value pairs (and that's part of JSF). But that method is called for every ajax request, so you should be seeing large URLs even with a4j:commandButton and any other ajax component.

              • 4. Re: FileUpload generates large Request Header with Request Parameters
                horowitzathome

                Okay, I have made the following small sample:

                 

                <h:body>

                       <f:view>

                             <rich:panel id="mainPanel">

                                    <h:form id="form" acceptcharset="UTF-8">

                 

                                           <h:inputText id="i1" value="#{uploadBean.input1}" />

                                           <h:inputText id="i2" value="#{uploadBean.input2}" />

                                           <h:inputText id="i3" value="#{uploadBean.input3}" />           

                       

                                           <a4j:commandButton id="cb1" action="#{uploadBean.action1}" value="rich" execute="i1" render="cb1"/>      

                                          

                                           <rich:fileUpload fileUploadListener="#{uploadBean.uploadListener}" id="uf1" maxFilesQuantity="1"

                                                  render="uf1" execute="i1" />           

                 

                                    </h:form>

                             </rich:panel>

                       </f:view>

                </h:body>

                 

                A click on the command button generates this URL:

                 

                http://localhost:8080/RichUploadWeb/faces/Upload1Main.xhtml

                 

                An upload generates this URL.

                 

                http://localhost:8080/RichUploadWeb/faces/Upload1Main.xhtml?rf_fu_uid=0.7716688169166446&javax.faces.partial.ajax=true&javax.faces.source=form:uf1&javax.faces.partial.execute=form:uf1&org.richfaces.ajax.component=form:uf1&form%3Ai1=t1&form%3Ai2=t2&form%3Ai3=t3&form_SUBMIT=1&javax.faces.ViewState=edK%2BkgJNPEMnisAx%2BibNqG3k4%2BtMkbKt1yU95ptLcXxh49ZV

                 

                Is it really necessary to append all the request parameters when uploading files? The problem is, when having the uploadControl within a from which has many other input controls, the URL can get quite a lot of request parameters and this is exactly the problem we have in our system.

                • 5. Re: FileUpload generates large Request Header with Request Parameters
                  michpetrov

                  I see. In the JSF ajax request the viewState is actually sent as the content of the request. As far as I can tell we had to put it in the URL because otherwise the request isn't processed correctly on servers that use Servlet 2.5. I'll take another look at it.

                   

                  And yes it is necessary to append all the parameters. The execute attribute is used on server side, it does not filter the values that are being sent. So we have to send everything, and the server then decides which values to use.

                  • 6. Re: FileUpload generates large Request Header with Request Parameters
                    horowitzathome

                    Hello,

                     

                    the file upload is a POST request. What I know so far is, that POST requests must not transmit form data via the URL but rather via the request body.

                     

                    In this case this POST request of the file upload transmits the form data via the URL, what in my opinion is not correct and makes terrible problems because usually you have the upload control embedded in a form with some other input controls which might contain large data. In my case I have some other input fields which can contain some KB of data. So when I now do the upload and the other input fields are filled with these data, I get from our web server an error that the URL exceeds the maximum allowed size (in our case about 12KB).

                     

                    So wouldn’t it be more correct to post the form data via the request body rather than via the URL?