[英]Parameter retrieval for HTTP PUT requests under IIS5.1 and ASP-classic?
I'm trying to implement a REST interface under IIS5.1/ASP-classic (XP-Pro development box). 我正在尝试在IIS5.1 / ASP-classic(XP-Pro开发箱)下实现REST接口。 So far, I cannot find the incantation required to retrieve request content variables under the PUT HTTP method. 到目前为止,我找不到在PUT HTTP方法下检索请求内容变量所需的咒语。
With a request like: 要求类似:
PUT http://localhost/rest/default.asp?/record/1336
Department=Sales&Name=Jonathan%20Doe%203548
how do I read Department
and Name
values into my ASP code? 如何将Department
和Name
值读取到我的ASP代码中?
Request.Form
appears to only support POST requests. Request.Form
似乎仅支持POST请求。 Request.ServerVariables
only gets me to header information. Request.ServerVariables
仅使我了解标头信息。 Request.QueryString
doesn't get me to the content either... Request.QueryString
也不能让我了解内容...
Based on the replies from AnthonyWJones and ars I went down the BinaryRead path and came up with the first attempt below: 根据AnthonyWJones和ars的回复,我沿BinaryRead路径前进,并提出了以下第一次尝试:
var byteCount = Request.TotalBytes;
var binContent = Request.BinaryRead(byteCount);
var myBinary = '';
var rst = Server.CreateObject('ADODB.Recordset');
rst.Fields.Append('myBinary', 201, byteCount);
rst.Open();
rst.AddNew();
rst('myBinary').AppendChunk(binContent);
rst.update();
var binaryString = rst('myBinary');
var contentString = binaryString.Value;
var parameters = {};
var pairs = HtmlDecode(contentString).split(/&/);
for(var pair in pairs) {
var param = pairs[pair].split(/=/);
parameters[param[0]] = decodeURI(param[1]);
}
This blog post by David Wang , and an HtmlDecode()
function taken from Andy Oakley at blogs.msdn.com, also helped a lot. 大卫·王(David Wang HtmlDecode()
此博客文章以及从HtmlDecode()
安迪·奥克利HtmlDecode()
Andy Oakley HtmlDecode()
提取的HtmlDecode()
函数也有很大帮助。
Doing this splitting and escaping by hand, I'm sure there are a 1001 bugs in here but at least I'm moving again. 手动进行拆分和转义,我确定这里有1001个bug,但至少我要再移动一次。 Thanks. 谢谢。
Unfortunately ASP predates the REST concept by quite some years. 不幸的是,ASP比REST概念早了很多年。
If you are going RESTFull then I would consider not using url encoded form data. 如果您要使用RESTFull,那么我会考虑不使用url编码的表单数据。 Use XML instead. 改用XML。 You will be able to accept an XML entity body with:- 您将可以通过以下方式接受XML实体主体:
Dim xml : Set xml = CreateObject("MSXML2.DOMDocument.3.0")
xml.async = false
xml.Load Request
Otherwise you will need to use BinaryRead on the Request object and then laboriously convert the byte array to text then parse the url encoding yourself along with decoding the escape sequences. 否则,您将需要在Request对象上使用BinaryRead,然后将字节数组费力地转换为文本,然后解析自己编码的网址以及对转义序列进行解码。
Try using the BinaryRead method in the Request object: 尝试在Request对象中使用BinaryRead方法:
http://www.w3schools.com/ASP/met_binaryread.asp http://www.w3schools.com/ASP/met_binaryread.asp
Other options are to write an ASP server component or ISAPI filter: 其他选项是编写ASP服务器组件或ISAPI筛选器:
http://www.codeproject.com/KB/asp/cookie.aspx http://www.codeproject.com/KB/asp/cookie.aspx
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.