什么是MSXML2.ServerXMLHTTP的默认内容类型?

时间:2022-05-14 04:26:32

In my previous question, I was accidentally sending token/value pairs with an text/xml Content-Type which resulted in nothing being sent. Tim C's insight into that problem was extremely helpful. Thanks again, Tim!

在我之前的问题中,我不小心发送了带有text / xml Content-Type的令牌/值对,导致没有发送任何内容。蒂姆C对这个问题的洞察力非常有帮助。蒂姆,再次感谢!

Looking back at the original sending code, I now realize that the setting of the ServerXMLHTTP's Content-Type to text/xml was a recent and erroneous addition. The sending code I posted in my question looked like this:

回顾一下原始的发送代码,我现在意识到将ServerXMLHTTP的Content-Type设置为text / xml是最近添加的错误。我在问题中发布的发送代码如下所示:

url = "www.receivingwebsite.com\asp\receivingwebpage.asp"
information = "UserName=Colt&PassWord=Taylor&Data=100"
Set xmlhttp = server.Createobject("MSXML2.ServerXMLHTTP")
xmlhttp.Open "POST", url, false
xmlhttp.setRequestHeader "Content-Type", "text/xml"
xmlhttp.send information

The actual sending code is really:

实际的发送代码实际上是:

url = "www.receivingwebsite.com\asp\receivingwebpage.asp"
information = "UserName=Colt&PassWord=Taylor&Data=100"
Set xmlhttp = server.Createobject("MSXML2.ServerXMLHTTP")
xmlhttp.Open "POST", url, false
xmlhttp.send information

...with no attempt to set the Content-Type before sending.

...在发送之前没有尝试设置Content-Type。

Unfortunately, the problem that originally lead me to ask for help still exists. My receiving classic asp page cannot see the information which is being posted by the ServerXMLHTTP object. The information is not in the request object's querystring or the form array. No matter what I do, I can't find the information but I know that it is being sent because when I change the content-type to application/x-www-form-urlencoded, I can see it in request.form array.

不幸的是,最初导致我寻求帮助的问题仍然存在。我收到的经典asp页面无法看到ServerXMLHTTP对象发布的信息。该信息不在请求对象的查询字符串或表单数组中。无论我做什么,我都找不到信息,但我知道它正在被发送,因为当我将内容类型更改为application / x-www-form-urlencoded时,我可以在request.form数组中看到它。

So what is the default content-type of the MSXML2.ServerXMLHTTP class? And where is my information when the sending class is using that default content-type?

那么MSXML2.ServerXMLHTTP类的默认内容类型是什么?当发送类使用默认内容类型时,我的信息在哪里?

Thanks in advance for any assistance! Peace, Colt Taylor

在此先感谢您的任何帮助!和平,柯尔特泰勒

1 个解决方案

#1


2  

ASP will only fill the form array if the content type of the POST is "application/x-www-form-urlencoded". Generally ServerXMLHTTP will not set the content type header so if you don't do it manually no content type header is sent.

如果POST的内容类型是“application / x-www-form-urlencoded”,ASP将仅填充表单数组。通常,ServerXMLHTTP不会设置内容类型标头,因此如果您不手动执行,则不会发送内容类型标头。

An exception to this is where you pass an XML Document as the parameter to send, in that case ServerXMLHTTP will set content type to "text/xml; charset=UTF-8".

例外情况是您将XML Document作为要发送的参数传递,在这种情况下,ServerXMLHTTP会将内容类型设置为“text / xml; charset = UTF-8”。

#1


2  

ASP will only fill the form array if the content type of the POST is "application/x-www-form-urlencoded". Generally ServerXMLHTTP will not set the content type header so if you don't do it manually no content type header is sent.

如果POST的内容类型是“application / x-www-form-urlencoded”,ASP将仅填充表单数组。通常,ServerXMLHTTP不会设置内容类型标头,因此如果您不手动执行,则不会发送内容类型标头。

An exception to this is where you pass an XML Document as the parameter to send, in that case ServerXMLHTTP will set content type to "text/xml; charset=UTF-8".

例外情况是您将XML Document作为要发送的参数传递,在这种情况下,ServerXMLHTTP会将内容类型设置为“text / xml; charset = UTF-8”。