tracker issue : CF-3694176

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

ColdFusion 10 RESTful Web Service Unable to Receive gzip'd (binary) body

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/

Reporter/Name(from Bugbase): Marc Giguere / Marc Giguere (Marc Giguere)

Created: 01/15/2014

Components: REST Services

Versions: 10.0

Failure Type:

Found In Build/Fixed In Build: Final / CF10_Update14

Priority/Frequency: Major / All users will encounter

Locale/System: English / Win 2008 Server R2 64 bit

Vote Count: 0

Problem Description:
In developing a new RESTful service using Cold Fusion 10, the 3rd party consuming the service is sending data in json format that is gzip compressed. When the data is received, Cold Fusion is unable to deflate/uncompress the information and as a result, the binary data received is in an unusable format. The following post on a 3rd party site illustrates the same situation as I have experienced and the attempt to update the web.xml configuration to use the additional filter to try and have the data be processed for decompression had no apparent impact/effect.

http://stackoverflow.com/questions/16858387/coldfusion-10-restful-web-service-unable-to-receive-gzipd-binary-body

Steps to Reproduce:
Use the files included in the zip file attached to submit a test HTTP post to a test REST service to demonstrate error.

Actual Result:
When you run the posting template, it will send gzip compressed data to the REST service, which will receive it and will throw an error when it attempts to run the DeserializeJSON() function on the data that was converted from the originally received binary information. The <cffile write> will capture the binary data and then this can be opened using a standard compression program (ie: WinZip) and you will see that the data within that file is a simple text document that holds the original JSON string that was compressed.

Cold Fusion appears to be unable to decompress the received information from the HTTP post and thus there is no way to use that data.

Expected Result:
Cold Fusion should proceed to detect that gzip data was received, decompress it and then return a valid representation of the compressed data to be used/manipulated.

Any Workarounds:
Going to attempt to use the built-in java libraries to manually decompress the data received to then make use of it, but this should not be required.

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

Watson Bug ID:	3694176

Deployment Phase:	Release Candidate

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

Cold Fusion 10, Updated through update 12

Server 2008 R2, SP1, IIS 7.5

Attachments:

  1. January 15, 2014 00:00:00: 1_CFBugData.zip
  2. January 22, 2014 00:00:00: 2_bug3694176.rar

Comments:

Added the GZipEncodingFilter to the jersey request and response filters in the web.xml
Comment by Paul N.
13695 | January 22, 2014 09:56:15 AM GMT
My original bug report noted that I attempted this on my server as well, and restarted the entire system and found that this had no change on the process. The GZip received data still did not properly get uncompressed. Can you perhaps share what you placed in your web.xml document and confirm that you successfully had it process a GZip based request?
Comment by External U.
13696 | January 22, 2014 09:59:56 AM GMT
Update your CFRestServlet in the web.xml like, <init-param> <param-name>com.sun.jersey.spi.container.ContainerRequestFilters</param-name> <param-value>coldfusion.rest.servlet.CFUriConnegFilter;com.sun.jersey.api.container.filter.GZIPContentEncodingFilter;coldfusion.rest.servlet.CFRequestFilter</param-value> </init-param> <init-param> <param-name>com.sun.jersey.spi.container.ContainerResponseFilters</param-name> <param-value>coldfusion.rest.servlet.CFResponseFilter;com.sun.jersey.api.container.filter.GZIPContentEncodingFilter</param-value> </init-param> Modify you service like, <cfcomponent name="TestRestService" rest="true" restpath="TestService"> <cffunction name="ProcessNewRequest" access="remote" returntype="Struct" httpmethod="POST"> <cfargument name="unCompressedData"> <cfdump var="#unCompressedData#" output="console"> <cfreturn unCompressedData> </cffunction> </cfcomponent> Here the change is I am extracting the body using a cfargument. Don't use GetHTTPRequest().content. Use cfargument. You need to restart your server. Also refresh your service after modifying the service. Please try and let me know. Thanks, Paul
Comment by Paul N.
13697 | January 22, 2014 10:07:36 AM GMT
Sorry for the double post below with my comment. I have gone ahead and tested what you outlined here and it did work! It may be worth adding to the documentation that speaks about REST that the preferred way to retrieve the information sent via a POST is to use the <cfargument> method and to note that this default argument alone is enough to retrieve the "content" of the data being sent from the other party. I had only come across the use of an argument via the stackoverflow post referred to above and checking through the CF docs site again, I still find no good information/examples that illustrate this. Thank you.
Comment by External U.
13698 | January 22, 2014 11:38:08 AM GMT
Merged the fix in cf10 hotfix branch.
Comment by Paul N.
13699 | July 24, 2014 01:49:07 AM GMT