2 Replies Latest reply on Dec 4, 2014 12:02 PM by mike124897

    Sending any non-POST-type request with data to CFC

    mike124897

      In CF 11 (Developer Edition), non-POST-type requests with data to CFC files seem to get stuck in ColdFusion. I don't believe I've changed anything in CF administration that could affect this, and as far as I can tell I haven't done anything to IIS that would break it either. The issue occurs with both of the CF applications that I'm working on.

       

      Requests to CFMs that contain data work using any of the CRUD methods (GET, POST, PUT, DELETE), and the IIS handlers are setup to accept all methods for both CFMs and CFCs.

       

      Can anyone else verify whether this issue with requests to CFCs exists in their environment?

       

      Example curl requests:

      # Requests to CFC with data
      curl -d 'test=123' -X 'GET' 'http://localhost/myapplication/component.cfc?method=test' # NO RESPONSE (TIMEOUT)
      curl -d 'test=123' -X 'PUT' 'http://localhost/myapplication/component.cfc?method=test' # NO RESPONSE (TIMEOUT)
      curl -d 'test=123' -X 'DELETE' 'http://localhost/myapplication/component.cfc?method=test' # NO RESPONSE (TIMEOUT)
      curl -d 'test=123' -X 'POST' 'http://localhost/myapplication/component.cfc?method=test' # Works fine
      
      # Requests to CFM with data
      curl -d 'test=123' -X 'GET' 'http://localhost/myapplication/component.cfm' # Works fine
      curl -d 'test=123' -X 'PUT' 'http://localhost/myapplication/component.cfm' # Works fine
      curl -d 'test=123' -X 'DELETE' 'http://localhost/myapplication/component.cfm' # Works fine
      curl -d 'test=123' -X 'POST' 'http://localhost/myapplication/component.cfm' # Works fine
      
      # Requests without data
      curl -X 'GET' 'http://localhost/myapplication/component.cfc?method=test' # Works fine
      curl -X 'PUT' 'http://localhost/myapplication/component.cfc?method=test' # Works fine
      curl -X 'DELETE' 'http://localhost/myapplication/component.cfc?method=test' # Works fine
      curl -X 'POST' 'http://localhost/myapplication/component.cfc?method=test' # Works fine
      
        • 1. Re: Sending any non-POST-type request with data to CFC
          BKBK Adobe Community Professional & MVP

          mike124897 wrote:

           

          In CF 11 (Developer Edition), non-POST-type requests with data to CFC files seem to get stuck in ColdFusion. I don't believe I've changed anything in CF administration that could affect this, and as far as I can tell I haven't done anything to IIS that would break it either. The issue occurs with both of the CF applications that I'm working on.

           

          Requests to CFMs that contain data work using any of the CRUD methods (GET, POST, PUT, DELETE), and the IIS handlers are setup to accept all methods for both CFMs and CFCs.

           

          Can anyone else verify whether this issue with requests to CFCs exists in their environment?

           

          Example curl requests:

          1. # Requests to CFC with data 
          2. curl -d 'test=123' -X 'GET' 'http://localhost/myapplication/component.cfc?method=test' # NO RESPONSE (TIMEOUT) 
          3. curl -d 'test=123' -X 'PUT' 'http://localhost/myapplication/component.cfc?method=test' # NO RESPONSE (TIMEOUT) 
          4. curl -d 'test=123' -X 'DELETE' 'http://localhost/myapplication/component.cfc?method=test' # NO RESPONSE (TIMEOUT) 
          5. curl -d 'test=123' -X 'POST' 'http://localhost/myapplication/component.cfc?method=test' # Works fine 

           

           

          You complicate things with too many flags. You could just do something like

           

          Get

          curl "http://localhost/myapplication/component.cfc?method=test&myArg=123"

           

          Post

          curl --data "myData=someData" "http://localhost/myapplication/component.cfc?method=test&myArg=123"

          • 2. Re: Sending any non-POST-type request with data to CFC
            mike124897 Level 1

            This is not "[complicating] things with too many flags". These types of requests are a requirement for many client-side APIs expecting a server-side RESTful implementation. These cURL requests are identical to browser XHR CRUD requests, sans a few headers. This issue occurs identically in browser requests in my tests. The CF 11 handler for IIS does not seem to generate a response for requests to CFCs when those requests contain certain elements.


            Another example I'm running into right now is POST requests containing JSON in the payload (include the "Content-Type: application/json" header for server to parse as JSON) for CFCs fail to generate a response when the "onRequestStart" function (application.cfc) returns false. This differs from requests for CFMs which, just as one would expect, return an empty response when "onRequestStart" returns false -- unless the "onRequestStart" function induces output, of course.

             

            The ideal resolution would perhaps be to provide CFMs to interface with components and then direct the AJAX requests toward the CFMs. Project restrictions prevent me from doing that though.

             

            Why do such requests cause the CF 11 handler to fail to generate a response, and is there a clean way to resolve this?