最近用python写一个脚本,功能很简单,就是在一个访问一个网页,填好一个表单,然后提交上去
可是一直提交不成功,跟踪了下后台的服务器,原来是一个POST参数名前多了一个换行‘\r\n'
又跟踪脚本,一切都是正常的
直到跟到这段代码:
def _send_output(self, message_body=None):
"""Send the currently buffered request and clear the buffer.
Appends an extra \\r\\n to the buffer.
A message_body may be specified, to be appended to the request.
"""
self._buffer.extend(("", ""))
msg = "\r\n".join(self._buffer)
print msg
del self._buffer[:]
# If msg and message_body are sent in a single send() call,
# it will avoid performance problems caused by the interaction
# between delayed ack and the Nagle algorithim.
if isinstance(message_body, str):
msg += message_body
message_bo