Grails
  1. Grails
  2. GRAILS-2017

grails 1.0RC3 HttpServletRequest: cannot retrieve POST data; the same code works in grails 0.5.6

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 1.0-RC3
    • Fix Version/s: 1.0-RC3
    • Component/s: Controllers
    • Labels:
      None
    • Environment:
      Windows XP SP2; java 1.6_01

      Description

      I've enclosed two project rar files , project name -> newapp.

      There is only one controller implemented in both projects -> TestMeController ; the code is identical in both.

      The included python script should be called as 'python testpost.py' . The script basically does a POST to
      http://localhot:8080/newapp/testme/testpost
      with "<?xml version="1.0" encoding="UTF-8"?>
      <req>Dummy request</req>"

      The server output when using newapp 0.5.6 is:


      User-Agent:Python post
      Content-Type:text/xml; charset="UTF-8"
      Content-Length:63
      Query string is: null; length is 63
      Param action -> testpost
      Param controller -> testme
      r is:java.io.BufferedReader@1427e6e; input stream: org.mortbay.jetty.servlet.Ser
      vletIn@7a8313
      Request data is : <?xml version="1.0" encoding="UTF-8"?>
      <req>Dummy request</req>;


      The server output when using grails 1.0RC3 is:


      [12422] controller.TestmeController User-Agent:Python post
      [12422] controller.TestmeController Content-Type:text/xml; charset="UTF-8"
      [12422] controller.TestmeController Content-Length:63
      [12422] controller.TestmeController Query string is: null; length is 63
      [12422] controller.TestmeController Param action -> testpost
      [12422] controller.TestmeController Param controller -> testme
      [12422] controller.TestmeController Param req -> [:]
      r is:java.io.BufferedReader@9875d1; input stream: org.mortbay.jetty.HttpParser$I
      nput@15f1ace
      Request data is : ;

      As you can see from above, the 1.0RC3 application does not receive any data in the input stream of HttpServletRequest . The same works perfectly in grails 0.5.6.

      The python code can be executed on Windows XP either thru native python or thru python installed using cygwin. The same test case can be written in groovy or thru other means as well as it is fairly trivial; let me know if you are unable to run it.

      1. newapp-0.5.6.rar
        222 kB
        Rahul
      2. newapp-1.0RC3.rar
        177 kB
        Rahul
      3. testpost.py
        1 kB
        Rahul

        Activity

        Hide
        Rahul added a comment -

        Note: the attached file newapp-0.5.6.rar has no WEB-INF directory to keep the size of project within 10 MB limit. You'll need to do a "grails init" to get it working in grails 0.5.6.

        Show
        Rahul added a comment - Note: the attached file newapp-0.5.6.rar has no WEB-INF directory to keep the size of project within 10 MB limit. You'll need to do a "grails init" to get it working in grails 0.5.6.
        Hide
        Graeme Rocher added a comment -

        The reason is Grails now automatically parses incoming XML requests and populates the params object with the XML. This is done based on the the detected request content format and the reason is XML is configured as a mime type handle in grails-app/conf/Config.groovy:

        grails.mime.types = [ html: ['text/html','application/xhtml+xml'],
                                              xml: ['text/xml', 'application/xml'],
                                             // etc.
        

        If you don't want XML handled like this you can remove the above XML entry from the configured mime types. If this works for you please close the issue.

        Show
        Graeme Rocher added a comment - The reason is Grails now automatically parses incoming XML requests and populates the params object with the XML. This is done based on the the detected request content format and the reason is XML is configured as a mime type handle in grails-app/conf/Config.groovy: grails.mime.types = [ html: ['text/html','application/xhtml+xml'], xml: ['text/xml', 'application/xml'], // etc. If you don't want XML handled like this you can remove the above XML entry from the configured mime types. If this works for you please close the issue.
        Hide
        Rahul added a comment -

        This is actually a new feature in grails 1.0 release as described by Graeme. I need to comment out

        " xml: ['text/xml', 'application/xml']" in grails.mime.types defined in Config.groovy file.

        It would help although to have documentation on the data types generated by grails for all params attributes added by this new feature.

        Show
        Rahul added a comment - This is actually a new feature in grails 1.0 release as described by Graeme. I need to comment out " xml: ['text/xml', 'application/xml'] " in grails.mime.types defined in Config.groovy file. It would help although to have documentation on the data types generated by grails for all params attributes added by this new feature.
        Hide
        Graeme Rocher added a comment -

        Bulk closing bunch of resolved issues

        Show
        Graeme Rocher added a comment - Bulk closing bunch of resolved issues

          People

          • Assignee:
            Graeme Rocher
            Reporter:
            Rahul
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development