我在尝试通过python复制POST时遇到了408请求超时错误。在
使用Chrome Dev工具时,我可以看到请求的有效负载如下所示:
------WebKitFormBoundaryrDYOkUiAtKl4GqZG
Content-Disposition: form-data; name="profile_pic"; filename="maxresdefault.jpg"
Content-Type: image/jpeg
------WebKitFormBoundaryrDYOkUiAtKl4GqZG--
{like-post}使用这个参数复制模块:
^{pr2}$我复制的帖子的标题与chrome开发工具中显示的官方帖子的标题相匹配。 当我从会话.post我得到了200个好的回复说它成功了。在
然而,正如你所猜到的,没有图像,因为我没有发送一个。在
看到我在移除负载时得到了200ok的响应,在添加负载时得到了408请求超时,这让我几乎可以肯定我是在搞砸实际的上传。在
我试过缩小图像大小之类的方法,但它给了我同样的错误。在
408请求超时也是即时的,在等待一段时间后,它实际上没有“超时”的暗示,它在会话.post是制造出来的。在
请看我如何执行此帖子:
r = session.post(URL, headers=headers, files=files)
print r.status_code, r.text
请参见files
变量是如何生成的:
profile_picture_path = self.user_details('avatar')
profile_picture_name = ntpath.basename(profile_picture_path)
files = {'profile_pic': (profile_picture_name, open(profile_picture_path), 'image/jpeg')}
目前没有回答
相关问题 更多 >
编程相关推荐