简体   繁体   English

在IIS5.1和ASP-classic下获取HTTP PUT请求的参数?

[英]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? 如何将DepartmentName值读取到我的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.

相关问题 在 asp-classic 中启用 javascript - enabling javascript in asp-classic 带有JavaScript图表的ASP经典 - asp-classic with a javascript chart asp-classic不起作用Internet Explorer中的Request.ServerVariables(“ HTTP_REFERER”) - asp-classic Not working Request.ServerVariables(“HTTP_REFERER”) in Internet Explorer 使用javascript在ASP-classic网站中字体颜色不会改变 - Font color won't change in ASP-classic site using javascript 尝试创建一个显示asp-classic变量值的消息框或警报 - Trying to create a messagebox or alert which displays the value of an asp-classic variable 如何在asp.net中的数组中获取值(或以asp-classic为佳) - How to get value in array in asp.net ( or asp-classic would be better) 尝试使用ASP-classic和jQuery根据数据库的结果自动选择一个下拉选项 - Trying to automatically select a dropdown option based off of a result from a database using ASP-classic and jQuery 如何在 ASP-Classic 或 WSH 环境中使用来自 VBScript 的 Javascript OO 类? - How can I use Javascript OO classes from VBScript, in an ASP-Classic or WSH environment? 在经典ASP中传递查询字符串参数时出错 - Error in passing Query string parameter in classic asp 升级IIS /经典ASP Javascript / JScript脚本引擎(到Chakra?) - Upgrading IIS/Classic ASP Javascript/JScript Scripting Engines (to Chakra?)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM