tracker issue : CF-4198568

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

Sending request with application/x-www-form-urlencoded Content-Type causes Jersey error

| View in Tracker

Status/Resolution/Reason: Closed/Withdrawn/NotABug

Reporter/Name(from Bugbase): Mosh Teitelbaum / Mosh Teitelbaum ()

Created: 04/28/2017

Components: REST Services

Versions: 2016

Failure Type: Incorrectly functioning

Found In Build/Fixed In Build: 2016.0.04.302561 /

Priority/Frequency: Normal / Unknown

Locale/System: English / Win 2012 Server x64

Vote Count: 0

Problem Description:

I'm developing an application that uses a REST API, using the built-in ColdFusion REST functionality, for the back-end.  Any request sent to the API using a Content-Type of "application/x-www-form-urlencoded" results in a Jersey error (i.e., the request never even reaches my code) with a response of:

{"Message":"Entity input stream has already been closed."}

I've tried submitting requests with a ton of other Content-Type values (e.g., "application/json", "text/plain", even "foo/bar") and they all work fine.  It is specifically with a Content-Type of "application/x-www-form-urlencoded" that this error happens.

Steps to Reproduce:

<cfhttp url="http://api.com/rest" method="post" result="httpResult">
	<cfhttpparam type="header" name="Content-Type" value="application/x-www-form-urlencoded" />
	<cfhttpparam type="body" value="foo=bar&this=that" />
</cfhttp>

Actual Result:

Status of "500 Internal Server Error"
Body of {"Message":"Entity input stream has already been closed."}

Expected Result:

Status of "200 OK" or whatever my code produces.

Any Workarounds:

No

Attachments:

Comments:

Mosh, The usage is incorrect, when the content-type is "application/x-www-form-urlencoded", then the data that should be sent will be of type "formfiled". Here is the sample snippet: <cfhttp url="http://api.com/rest" method="post" result="res"> <cfhttpparam type="header" name="Content-Type" value="application/x-www-form-urlencoded" /> <cfhttpparam type="formfield" name="foo" value="thisandthat" /> </cfhttp> <cfdump var="#res#"> <cfcomponent rest="true" restPath="/restBug" produces="text/plain" > <cffunction name="test" access="remote" returnType="String" httpMethod="POST" produces="text/plain" consumes="application/x-www-form-urlencoded"> <cfargument name="foo" type="string" restargsource="FORM"> <cfset res="Hello " & foo> <cfreturn res> </cffunction> </cfcomponent>
Comment by HariKrishna K.
865 | May 05, 2017 11:15:30 AM GMT