使用#form#和#getHttpRequestData()#和字符集有什么区别? [英] What's the difference between using #form# and #getHttpRequestData()# with regard to charset?

查看:195
本文介绍了使用#form#和#getHttpRequestData()#和字符集有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个coldfusion页面,uni.cfm:

 < cfprocessingdirective pageencoding =utf-8> 
< cfscript>

< cfdump var =#form.a#label =form>
< cfdump var =#getHttpRequestData()。content#label =form2>发送以下HTTP请求在返回的html中首先生成字符串,然后输入以下HTTP请求:


$ b <
,然后是字符串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 =为什么#form.a#不能正确处理二进制字符串,而getHttpRequestData()是什么?

/ p>

解决方案

让发件人将内容类型更改为 multipart / form-data 没有url编码工作像一个魅力:

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

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

ΠΣΩ
--AaB03x--

然后能够使用#form.a#并获得正确的字符串!


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?

解决方案

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!

这篇关于使用#form#和#getHttpRequestData()#和字符集有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆