使用asyncore/asynchat的http/https客户端库

async_http的Python项目详细描述


原点

这个包最初是作为一种概念证明github的要点编写的 2011年12月25日,约西亚·卡尔森。此更新包是版权所有的 2012年,并在gnu lgpl v2.1许可下发布。

说明

这个包提供了通过异步连接到http服务器的能力。 和Asynchhat模块,以尝试下载文件或以其他方式集成 从异步派生服务中连接到其他服务。

下载文件

包含的异步http.get模块,可在命令行上使用:
$python-m async_http.get<;url列表>;

…将并行获取提供的URL。如果你查一下 py模块,您可以看到如何重写http_body(),http_done(), 和http_close()方法来(例如)远程获取内容 将它重定向到其他地方。

通过从下载文件中正确地进行子类化,您可以为远程文件提供类似的服务 对于此处请求的功能: http://code.google.com/p/pyftpdlib/issues/detail?id=197

发出OAuth请求

包含的async_http.oauth模块,可在命令行上使用:
$python-m async_http.oauth ckey,csecret[tkey,tsecret]<;url>;

…将对提供的具有给定URL的OAuth 1.0A请求执行 客户端密钥和机密,带有可选的令牌密钥和机密(您的url将 确定是否需要某种访问或请求令牌)。

功能

API

如果要为事件编写自己的处理程序,请从 _ http.asynchttprequest,并重写以下一个或多个方法:

def http_setup(self):
    '''
    Called just before the connection is set up. You can manipulate
    headers, request body, etc.
    '''

def http_response(self):
    '''
    Called after the response is read. You can handle redirects, perform
    additional logging, start a reply in a proxy, etc.
    '''

def http_body(self):
    '''
    Called at the end of every chunk with chunked transfer encoding, and
    any time data is read for the body otherwise.
    '''

def http_chunk(self):
    '''
    Called after every chunk with the chunked transfer encoding,
    immediately after the body callback.
    '''

def http_done(self):
    '''
    Called when the body has finshed being transferred. This will not be
    called when there is an error.
    '''

def http_close(self):
    '''
    Called when the connection has been closed.
    '''

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java是否存在这样一种场景:Java7的Hashmap实现优于Java8的实现   java如何打印这些完整的数组?   java BuildException:未能执行aapt   java如何使用类。未知类型的集合返回的cast()   java准备语句返回错误的值   webview 安卓中的java显示身份验证对话框   java如何重命名列名JPA Hibernate   java查询从特定用户和特定时间段的Oracle表(通过比较原始表和备份表)中选择修改的行   java Youtube视频仅在三星S6设备上加载时自动暂停   未调用java RecyclerView getItemViewType   使用JSch setCommand执行带有源选项的java Shell ping命令时失败   java Hibernate:无法删除|删除分离的实例   Java Spring@MappedSuperclass字段作为子类中的@Id字段   java Android:确定单击了哪个按钮,因为该按钮未在xml中定义   如何计算java阵列内存使用率   使用Java查找按字母顺序排列的第一个字符串   javascript注销功能刷新页面,但页面仍已登录   当接口作为参数提供时,java依赖项注入不起作用   java中带原语的字符串扭曲