我正在研究这个服务器端的asp脚本。它应该从Web应用程序接收xml流并将其保存在xml文件中。问题是我无法读取此流。我使用了不同的方法,似乎找不到合适的方法。另一件事是测试我正在使用rest console add for chrome并且似乎没有问题但是当我的客户端发送流时我无法读取它并且它们收到代码500错误。
起初我尝试以二进制模式读取流然后转换它
function readContent()
dim a,b
a=Request.TotalBytes
b=Request.BinaryRead(a)
writeInLogFile(" ")
writeInLogFile(Time & Request.ServerVariables("ALL_RAW"))
writeInLogFile(Time & " Data read in binary mode with a size of " & a)
readContent = URLDecode(BytesToStr(b))
writeInLogFile(Time & " the length of the converted string is : "& len(readContent))
end function
但这是我一直在我的日志文件
17:12:10Content-Length: 8416 Content-Type: application/x-www-form-urlencoded; charset=UTF-8 Authorization: Basic Host: User-Agent: Jakarta Commons-HttpClient/2.0.2 17:12:10 Data read in binary mode with a size of 8416 17:12:10 Converting binary to string
然后当我尝试编写转换后的字符串
时崩溃然后我切换到request.form
function readContent()
'writeInLogFile(Time & " " & URLDecode(Request.Form))
writeInLogFile(Time & Request.ServerVariables("ALL_RAW"))
readContent = URLDecode(Request.Form)
writeInLogFile(Time & " the length of the converted string is : "& len(readContent))
end function
但是当通过休息控制台进行测试时,一切正常,当实际从我的客户端接收流时,它就会崩溃。
任何人遇到类似的问题,或者知道如何解决这个问题
提前致谢
更新:
这里是解码功能
FUNCTION URLDecode(str)
'// This function:
'// - decodes any utf-8 encoded characters into unicode characters eg. (%C3%A5 = å)
'// - replaces any plus sign separators with a space character
'//
'// IMPORTANT:
'// Your webpage must use the UTF-8 character set. Easiest method is to use this META tag:
'// <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
'//
Dim objScript
Set objScript = Server.CreateObject("ScriptControl")
objScript.Language = "JavaScript"
URLDecode = objScript.Eval("decodeURIComponent(""" & str & """.replace(/\+/g,"" ""))")
Set objScript = NOTHING
'writeInLogFile(Time & " the length of the converted string is : "& len(URLDecode))
END FUNCTION
答案 0 :(得分:0)
客户端表示将发送的编码与流实际发送的编码不同。
Request.Form就是答案。