What's the difference between using #form# and #getHttpRequestData()# with regard to charset?

随声附和 提交于 2019-12-07 12:35:18

问题


I have a coldfusion page, uni.cfm:

<cfprocessingdirective pageencoding="utf-8">
<cfscript>

<cfdump var="#form.a#" label="form">
<cfdump var="#getHttpRequestData().content#" label="form2">

Sending the following HTTP request produces in the returned html first the string "???", then the string "a=ΠΣΩ".

POST http://localhost:8080/uni/unicode.cfm HTTP/1.1
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
User-Agent: unicli
Host: localhost:8080
Content-Length: 8
Pragma: no-cache

a=ΠΣΩ

Why does #form.a# NOT process the binary string correctly, while getHttpRequestData() does?


回答1:


Having the sender change content-type to multipart/form-data with NO url-encoding worked like a charm:

POST *URL* HTTP/1.1
Content-Type: multipart/form-data; boundary=AaB03x
Content-Length: 145

--AaB03x
Content-Disposition: form-data; name="a"

ΠΣΩ
--AaB03x--

Then able to use #form.a# and get the right string!



来源:https://stackoverflow.com/questions/10853622/whats-the-difference-between-using-form-and-gethttprequestdata-with-regar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!