我已经编写了一个,要获得对控制面板的访问,您必须填写一个令牌。此令牌被发送到send服务器,然后send服务器使用控制面板进行回复。
所有工作正常,从我的计算机上的令牌工作的每一次-然而,从iOS设备,它不能工作90%的时间>一个令牌不是发送的大部分时间!
HTML:
<!DOCTYPE html>
<html>
<head>
<title>Drakon</title>
<link rel="stylesheet" type="text/css" href="access.css">
</head>
<body>
<div class="login">
<div class="heading">
<h2>Gain access</h2>
<form method="POST">
<div class="input-group input-group-lg">
<span class="input-group-addon"><i class="fa fa-lock"></i></span>
<input name="token" type="password" class="form-control" placeholder="Token">
</div>
<button type="submit" class="float">Validate</button>
</form>
</div>
</div>
</body>
</html>这是我从iOS设备收到的后请求:
POST / HTTP/1.1\r\nHost: 192.168.2.4:8000\r\nReferer: http://192.168.2.4:8000/\r\nContent-Type: application/x-www-form-urlencoded\r\nAccept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\nAccept-Language: nl-nl\r\nAccept-Encoding: gzip, deflate\r\nOrigin: http://192.168.2.4:8000\r\nContent-Length: 10\r\nConnection: keep-alive\r\nUser-Agent: Mozilla/5.0 (iPad; CPU OS 7_1_2 like Mac OS X) AppleWebKit/537.51.2 (KHTML, like Gecko) Version/7.0 Mobile/11D257 Safari/9537.53\r\n\r\n我应该得到的,有时也会因为某种原因得到:
POST / HTTP/1.1\r\nHost: 192.168.2.4:8000\r\nReferer: http://192.168.2.4:8000/\r\nContent-Type: application/x-www-form-urlencoded\r\nAccept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\nAccept-Language: nl-nl\r\nAccept-Encoding: gzip, deflate\r\nOrigin: http://192.168.2.4:8000\r\nContent-Length: 11\r\nConnection: keep-alive\r\nUser-Agent: Mozilla/5.0 (iPad; CPU OS 7_1_2 like Mac OS X) AppleWebKit/537.51.2 (KHTML, like Gecko) Version/7.0 Mobile/11D257 Safari/9537.53\r\n\r\ntoken=lucas不同之处:在正确的一个(第二个),在结尾有一个token=lucas。为什么iOS设备有时不发送此令牌以及post请求?我在监督什么吗?
在糟糕的情况下,所有这些都失败了;设备甚至没有被重定向到主页,就像在错误的令牌之后应该做的那样。
请求是通过safari浏览器在iOS device上发送的,而不是iOS自定义应用程序。
发布于 2015-06-03 06:10:27
尝试将enctype="multipart/form-data"添加到表单参数中。
发布于 2020-08-10 14:33:35
我也遇到了同样的问题。
后来我发现浏览器实际上是在发送POST有效负载。但是,在没有有效负载的情况下读取头时,python read()函数将被返回。
将代码更改为读取内容长度标头,并再次使用read(content_length)获取有效负载,如果未使用标头读取有效负载。
https://stackoverflow.com/questions/30404576
复制相似问题