Skip to content

Latest commit

History

11 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

libeasyhttp

LICENSE

简易的http请求库

🎈使用方法

  1. HTTP_RESPONSE get(const char *url, HEADERS *headers);
#include"libeasyhttp/easy-http.h"intmain(void) {
HEADERS*headerList=NULL;
headerList=addHeader(headerList, "Content-Type", "text/html; charset=utf-8");
headerList=addHeader(headerList, "User-Agent", "ASXE");
HTTP_RESPONSEhttpResponse=get("https://www.asxe.vip/", headerList);
printf("%s", httpResponse.text);
return0;
}
  1. HTTP_RESPONSE post(const char *url, HEADERS *headers, POST_DATA *postData);
#include"libeasyhttp/easy-http.h"intmain(void) {
HEADERS*headerList=NULL;
POST_DATA*postData=NULL;
headerList=addHeader(headerList, "User-Agent", "ASXE");
postData=addData(postData, "q", "测试");
HTTP_RESPONSEhttpResponse=post("http://127.0.0.1:1314/search/", headerList, postData);
printf("%s", httpResponse.text);
return0;
}

HTTP_RESPONSE结构定义:

typedefstructHTTP_RESPONSE {
longstatus; //请求状态码char*text; //文本doubletotal_time; //请求耗时
} HTTP_RESPONSE;

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

🎉许可证

MIT

🎁Stars

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

About

简易的http请求库,方便的发送get以及post请求。

Topics

Resources

Stars

8 stars

Watchers

1 watching

Forks

Packages

Contributors

Languages