访问请求的机身采用传统的ASP(从iOS版客户端转贴)? [英] Accessing a request's body (POSTed from iOS client) using classic ASP?
问题描述
我如何访问哪些已发布的客户端,以我的经典ASP服务器?
我知道,还有就是Request.Forms变量,但使用表单客户端的请求没有做成。
该客户端请求的身体是只使用一个标准的POST发言中的字符串。
谢谢
How do I access what has been posted by a client to my classic ASP server? I know that there is the Request.Forms variable, but the client's request was not made using a Form. The client request's body is just a string made using a standard POST statement. Thanks
推荐答案
你需要读取请求字节,如果通过客户端发送请求内容类型不形成数据。在这种情况下,请求不是表单数据通过名称 - 值对访问的,所以你不能使用Request.Form集合。我建议调查了BinaryRead 方法。
读取发布的数据,并转换成字符串:
You need to read request bytes if content type of request sent by client is not form data. In this case, request is not a form-data that is accessible through name-value pairs so you cannot use Request.Form collection. I suggest investigate the BinaryRead method.
Reading posted data and convert into string :
If Request.TotalBytes > 0 Then
Dim lngBytesCount
lngBytesCount = Request.TotalBytes
Response.Write BytesToStr(Request.BinaryRead(lngBytesCount))
End If
Function BytesToStr(bytes)
Dim Stream
Set Stream = Server.CreateObject("Adodb.Stream")
Stream.Type = 1 'adTypeBinary
Stream.Open
Stream.Write bytes
Stream.Position = 0
Stream.Type = 2 'adTypeText
Stream.Charset = "iso-8859-1"
BytesToStr = Stream.ReadText
Stream.Close
Set Stream = Nothing
End Function
希望它帮助。
更新#1:
随着使用JScript
Update #1:
With using JScript
if(Request.TotalBytes > 0){
var lngBytesCount = Request.TotalBytes
Response.Write(BytesToStr(Request.BinaryRead(lngBytesCount)))
}
function BytesToStr(bytes){
var stream = Server.CreateObject("Adodb.Stream")
stream.type = 1
stream.open
stream.write(bytes)
stream.position = 0
stream.type = 2
stream.charset = "iso-8859-1"
var sOut = stream.readtext()
stream.close
return sOut
}
这篇关于访问请求的机身采用传统的ASP(从iOS版客户端转贴)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!