微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

libghttp C 语言的 HTTP 库

程序名称:libghttp

授权协议: 未知

操作系统: Linux

开发语言: C/C++

libghttp 介绍

libghttp 是一个很好用的 http 库,这个库十分的方便使用,它能够轻松地实现同步和异步的 Http 请求。

示例代码

#include <ghttp.h>
int main(int argc, char *argv[])
{
    char *uri = "http://www.oschina.net/";
    gHTTP_Request *request = NULL;
    ghttp_status status;
    char *buf;
    int bytes_read;
    
    request = gHTTP_Request_new();
    if(ghttp_set_uri(request, uri) == -1)
        exit(-1);
    if(ghttp_set_type(request, ghttp_type_get) == -1)
        exit(-1);
    ghttp_prepare(request);
    status = ghttp_process(request);
    if(status == ghttp_error)
        exit(-1);
    /* OK, done */
    printf("Status code -> %d\n", ghttp_status_code(request));
    buf = ghttp_get_body(loader->request);
    bytes_read = ghttp_get_body_len(loader->request);
    return 0;
}

libghttp 官网

http://libghttp.sourcearchive.com/

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐