调试python网络服务 [英] debugging python web service

查看:21
本文介绍了调试python网络服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用此处的说明,尝试检查正在执行的 HTTP 命令发送到我的网络服务器.

I am using the instructions found here, to try to inspect the HTTP commands being sent to my webserver.

但是,我没有看到如教程中建议的那样在控制台上打印 HTTP 命令.有谁知道如何在 CLI 中显示/调试 HTTP 命令?

However, I am not seeing the HTTP commands being printed on the console as suggested in the tutorial. Does anyone know how to display/debug the HTTP commands at the CLI?

我在 Linux Ubuntu 上运行 Python 2.6.5

I am running Python 2.6.5 on Linux Ubuntu

推荐答案

教程信息似乎已弃用.

现在使用 urllib2 进行调试的正确方法是:

Correct way to debug with urllib2 nowadays is:

import urllib2
request = urllib2.Request('http://diveintomark.org/xml/atom.xml')
opener = urllib2.build_opener(urllib2.HTTPHandler(debuglevel=1))    
feeddata = opener.open(request).read()

使用 urllib 进行调试的工作方式仍然是旧的.

Debugging with urllib works the old way though.

这篇关于调试python网络服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆