Git Product home page Git Product logo

libeasyhttp's Introduction

libeasyhttp

LICENSE

简易的http请求库

🎈使用方法

  1. HTTP_RESPONSE get(const char *url, HEADERS *headers);
#include "libeasyhttp/easy-http.h"

int main(void) {
    HEADERS *headerList = NULL;
    
    headerList = addHeader(headerList, "Content-Type", "text/html; charset=utf-8");
    headerList = addHeader(headerList, "User-Agent", "ASXE");
    
    HTTP_RESPONSE httpResponse = get("https://www.asxe.vip/", headerList);
    printf("%s", httpResponse.text);
    return 0;
}
  1. HTTP_RESPONSE post(const char *url, HEADERS *headers, POST_DATA *postData);
#include "libeasyhttp/easy-http.h"

int main(void) {
    HEADERS *headerList = NULL;
    POST_DATA *postData = NULL;
    
    headerList = addHeader(headerList, "User-Agent", "ASXE");
    
    postData = addData(postData, "q", "测试");
    
    HTTP_RESPONSE httpResponse = post("http://127.0.0.1:1314/search/", headerList, postData);
    printf("%s", httpResponse.text);
    return 0;
}

HTTP_RESPONSE结构定义:

typedef struct HTTP_RESPONSE {
long status; //请求状态码
char *text; //文本
double total_time; //请求耗时
} HTTP_RESPONSE;

注意:你所定义的headerListpostData不需要free(),我已经帮你处理了。

🎉许可证

MIT

🎁Stars

如果本项目对你有帮助,就来个小小的stars哦。

libeasyhttp's People

Contributors

asxez avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

dimonwoo

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.