将绝对URI更改为HTTP POST标头中的相对URI [英] Changing absolute URI to relative in HTTP POST header
问题描述
我有以下POST
请求:
POST http://blah/Request HTTP/1.1
Host: blah
Content-Length: 322
Proxy-Connection: Keep-Alive
<?xml version="1.0"?>
<Envelope>
<Header>
<UserID>uid</UserID>
<Password>pass</Password>
<SessionID />
<RequestType>GetDetails</RequestType>
<POSCompany>01</POSCompany>
<PackageType>DATA</PackageType>
<ActionType>READ</ActionType>
<SnoopUserID />
</Header>
<Body>
<MagicNumber>124</MagicNumber>
</Body>
</Envelope>
此操作失败,并显示错误-(405)不支持方法
This is failing with the error - (405) Method not supported
显然可以在服务器上运行的XML示例是相同的,但是标头包含行POST /Request HTTP/1.1
而不是POST http://blah/Request HTTP/1.1
.
An example XML which apparently works on the server is the same but the header has the line POST /Request HTTP/1.1
instead of POST http://blah/Request HTTP/1.1
.
我不知道这是否是问题,但我正在尝试消除所有可能性.但是,我无法获取POST
请求URI是相对的而不是绝对的.有水做吗?
I don't know if this is the problem but I am trying to eliminate all possibilites. However, I cannot get the POST
request URI to be relative and not absolute. Is there a wat to do this?
以下是用于发送XML的代码.
The following is the code used for sending the XML.
Public Sub SendXML(ByVal file As String)
Dim reader As New StreamReader(file)
Dim data As String = reader.ReadToEnd()
reader.Close()
Dim request As HttpWebRequest = WebRequest.Create("http://blah/Request")
request.Method = "POST"
System.Net.ServicePointManager.Expect100Continue = False
Dim bytes As Byte() = System.Text.Encoding.ASCII.GetBytes(data)
request.ContentLength = bytes.Length
Dim oStreamOut As Stream = request.GetRequestStream()
oStreamOut.Write(bytes, 0, bytes.Length)
oStreamOut.Close()
Dim response As HttpWebResponse = request.GetResponse()
End Sub
在此处根据 405-不允许的方法HttpWebRequest
推荐答案
405错误通常在POST方法中出现.您可能正在尝试 在网站上介绍某种输入形式,但不是所有的ISP 允许处理表单所需的POST方法.
405 errors often arise with the POST method. You may be trying to introduce some kind of input form on the Web site, but not all ISPs allow the POST method necessary to process the form.
所有405个错误都可以追溯到Web服务器的配置和 控制对网站内容的访问的安全性,因此也应如此 您的ISP很容易解释.
All 405 errors can be traced to configuration of the Web server and security governing access to the content of the Web site, so should easily be explained by your ISP.
这篇关于将绝对URI更改为HTTP POST标头中的相对URI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!