tracker issue : CF-3581691

select a category, or use search below
(searches all categories and all time range)
Title:

Calling GetHttpRequestData() in application.cfm breaks REST services

| View in Tracker

Status/Resolution/Reason: Closed/Withdrawn/NotABug

Reporter/Name(from Bugbase): kurt ronshausen / kurt ronshausen (KRonshausen)

Created: 06/19/2013

Components: REST Services

Versions: 10.0

Failure Type: Incorrect w/Workaround

Found In Build/Fixed In Build: Final /

Priority/Frequency: Major / All users will encounter

Locale/System: English / Windows 7 64-bit

Vote Count: 1

Problem Description:
Calling GetHttpRequestData() causes the body argument in rest services will always be empty string
Steps to Reproduce:
Place attachment contents in your wwwroot and navigate to /index.cfm.
Actual Result:
result.filecontent should contain '{"BODY":"This is a test string"}'
Expected Result:
result.filecontent contains  '{"BODY":""}'
Any Workarounds:
I was using this function inspect headers.
Using getpagecontext().getRequest().getHeader(string) did not cause this issue

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	3581691

External Customer Info:
External Company:  
External Customer Name: KRonshausen
External Customer Email:  
External Test Config: My Hardware and Environment details:



ColdFusion 10 Update 10 

Apache 2.2.21

Windows 7 64 bit

Attachments:

  1. June 20, 2013 00:00:00: 1_wwwroot.zip

Comments:

I have not tried this with application.cfc
Comment by External U.
15160 | June 19, 2013 05:15:38 PM GMT
I can verify this bug also exists when consuming a ColdFusion published web services. It appears to be an ages old bug! * http://www.bennadel.com/blog/1602-GetHTTPRequestData-Breaks-The-SOAP-Request-Response-Cycle-In-ColdFusion.htm * http://www.petefreitag.com/item/733.cfm * http://stackoverflow.com/questions/3980194/gethttprequestdata-and-soap-web-service-request-in-coldfusion-8 My experience is that even referencing getHttpRequestData() in an if/else causes the same fatal error. I can confirm that the workaround offer by @KRonshausen works. My Hardware and Environment details: ColdFusion 10 Update 11 Apache 2.2.21 Windows Server 2008 R2 Service Pack 1 (64 bit)
Comment by External U.
15161 | July 17, 2013 05:25:31 AM GMT
Richard Herbert (UK) 3:55:31 AM PDT Jul 17, 2013 I can verify this bug also exists when consuming a ColdFusion published web services. It appears to be an ages old bug! * http://www.bennadel.com/blog/1602-GetHTTPRequestData-Breaks-The-SOAP-Request-Response-Cycle-In-ColdFusion.htm * http://www.petefreitag.com/item/733.cfm * http://stackoverflow.com/questions/3980194/gethttprequestdata-and-soap-web-service-request-in-coldfusion-8 My experience is that even referencing getHttpRequestData() in an if/else causes the same fatal error. I can confirm that the workaround offer by @KRonshausen works. My Hardware and Environment details: ColdFusion 10 Update 11 Apache 2.2.21 Windows Server 2008 R2 Service Pack 1 (64 bit)
Vote by External U.
15171 | July 17, 2013 05:26:35 AM GMT
On CF9, I'm using getHttpRequestData().headers to identify whether a request has the header "X-Requested-With" to determine if the request is ajax or not. During PCI scans, we occasionally get a "String index out of range: -1" error. When we dump the CGI scope, CONTENT_TYPE = " (that's just a single quote). We haven't tested this in on CF10 yet since we haven't migrated to production or subjected websites to third-party scanning yet.
Comment by External U.
15162 | July 17, 2013 11:24:08 AM GMT
GetHttpRequestData by default retrieves the body of the request and once it is retrieved, it cannot be read again. If you need to retrieve anything other than body from the request, use GetHttpRequestData(false). The expected behavior mentioned in the bug was indeed true with JRun application server but it would not work for any other application server. Not a bug.
Comment by Rupesh K.
15163 | September 04, 2013 11:31:56 AM GMT
Hi Rupesh, Are you suggesting an undocumented feature as a workaround for a regression? And saying the regression is not a bug b/c the underlying application server was changed? 1) Documentation says GetHTTPRequestData() does not accept any parameters (doc bug) 2) The developer does not care if CF's internals were changed. A backward-compat regression was introduced. (behavior bug) I'm seeing 2 bugs here, not 0. I think this boolean parameter (and the behavior difference btwn JRun/Tomcat) should've been documented before suggesting it as a workaround. Instead of GetHTTPRequestData() and <cfhttp> both reading the request body from the underlying app server directly, a copy of this request body should be stored into another internal variable so that it can be available to both GetHTTPRequestData() and <cfhttp>. That way GetHTTPRequestData() can't steal it and leave <cfhttp> empty-handed. Thanks, -Aaron
Comment by External U.
15164 | November 28, 2014 05:14:14 PM GMT
* <cfhttp> should've been REST
Comment by External U.
15165 | November 28, 2014 07:35:51 PM GMT
I definitely agree that this is a but, but I didn't even know about the getHttpRequestData(False) possibility. I have documented that this problem still exists in ColdFusion 11 and that this (False) approach works in both CF10 and CF11 to work around. http://www.bennadel.com/blog/2824-gethttprequestdata-may-break-your-request-in-coldfusion-but-gethttprequestdata-false-may-not.htm Also, just to be clear, the problem is not calling getHttpRequestData() multiple times - you can safely do this once you are inside an event handler (either implicitly or explicitly). The problem seems to only become symptomatic when the first call is inside the ColdFusion framework's pseudo-constructor.
Comment by External U.
15166 | April 28, 2015 06:50:05 AM GMT
Hi Ben, Thanks very much for digging deeper into this! It's unfortunate that Adobe sometimes treats blog comments and ticket comments as an extension of their documentation and release notes. Thanks!, -Aaron @Rupesh, did you ever see my reply here?
Comment by External U.
15167 | April 28, 2015 07:45:28 AM GMT
1) Documentation says GetHTTPRequestData() does not accept any parameters (doc bug) 2) The developer does not care if CF's internals were changed. A backward-compat regression was introduced. (behavior bug)
Comment by External U.
15168 | August 17, 2015 07:01:06 AM GMT
Adobe, 1) You broke backward-compat when switching from JRun to Tomcat (behavior bug) 2) You never documented getHTTPRequestData(false) (doc bug) There are 2 things to fix here. Please re-open this ticket to fix #1. Please correct the docs to fix #2. Thanks!, -Aaron
Comment by External U.
15169 | September 15, 2015 12:46:38 PM GMT
Adobe, This ticket's "Reason:NotABug" is not very appropriate/considerate b/c backward-compat was broken here. JRun allowed the body of the request to still be retrieved after GetHttpRequestData(true) (where true is the default value) was called. Could you please at least change the "Reason" to a more appropriate/considerate reason since backward-compat was broken? Thanks!, -Aaron
Comment by External U.
15170 | November 13, 2015 01:23:58 AM GMT
IsABug
Comment by Aaron N.
27865 | May 18, 2018 07:47:36 AM GMT
Backward-compat (JRun behavior) should've been maintained.
Comment by Aaron N.
27866 | May 18, 2018 07:50:06 AM GMT