
尝试看看您的服务器实际上返回了什么!它可能不是有效的HTTP响应。您可以使用以下方式将原始的http请求发送到服务器:
from socket import sockethost = 'localhost'port = 80path = "/your/url"xmlmessage = "<port>0</port>"s = socket()s.connect((host, port))s.send("POST %s HTTP/1.1rn" % path)s.send("Host: %srn" % host)s.send("Content-Type: text/xmlrn")s.send("Content-Length: %drnrn" % len(xmlmessage))s.send(xmlmessage)for line in s.makefile(): print line,s.close()响应应类似于:
HTTP/1.1 200 OK<response headers><response body>
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)