debugging python web service

家住魔仙堡 提交于 2019-12-04 11:17:41

问题


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

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?

I am running Python 2.6.5 on Linux Ubuntu


回答1:


The tutorial information seems to be deprecated.

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()

Debugging with urllib works the old way though.



来源:https://stackoverflow.com/questions/4404654/debugging-python-web-service

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!