HTTP POST问题
用以下代码:
Function HttpPOST(ByVal Url As String, ByVal PostData As String, Optional ByVal Time As Integer = 0) As Stream
Dim req As HttpWebRequest
If Time <> 0 Then
End If
req = WebRequest.Create(Url)
req.Method = "POST"
Dim bytesData() As Byte = System.Text.Encoding.ASCII.GetBytes(PostData)
req.ContentLength = bytesData.Length
Dim postStream As Stream = req.GetRequestStream()
postStream.Write(bytesData, 0, bytesData.Length)
Dim res As HttpWebResponse = req.GetResponse()
Return res.GetResponseStream
End Function
将返回流转换为文本之后,发现怎么都是失败的,POST文本没有问题,因为在其他编程语言里面都能成功.
应该怎么改?
提供一组测试数据:
地址:http://www.5d6d.com/logging.php?action=login&referer=bbscp.php
POST数据:username=用户名&password=密码&submit=+&formhash=36a2650c&loginfield=username&loginsubmit=true