GNU libmicrohttpd 是一个小型的嵌入式 HTTP 服务器 的 C 类库,支持 HTTP 1.1 可以同时侦听多个端口,下面是一个最为简单的使用例子:
#include <microhttpd.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#define PAGE "<html><head><title>libmicrohttpd demo</title>"\
"</head><body>libmicrohttpd demo</body></html>"
static int ahc_echo(void * cls,
struct MHD_Connection * connection,
const char * url,
const char * method,
const char * version,
const char * upload_data,
size_t * upload_data_size,
void ** ptr) {
static int dummy;
const char * page = cls;
struct MHD_Response * response;
int ret;
if (0 != strcmp(method, "GET"))
return MHD_NO; /* unexpected method */
if (&dummy != *ptr)
{
/* The first time only the headers are valid,
do not respond in the first round... */
*ptr = &dummy;
return MHD_YES;
}
if (0 != *upload_data_size)
return MHD_NO; /* upload data in a GET!? */
*ptr = NULL; /* clear context pointer */
response = MHD_create_response_from_data(strlen(page),
(void*) page,
MHD_NO,
MHD_NO);
ret = MHD_queue_response(connection,
MHD_HTTP_OK,
response);
MHD_destroy_response(response);
return ret;
}
int main(int argc,
char ** argv) {
struct MHD_Daemon * d;
if (argc != 2) {
printf("%s PORT\n",
argv[0]);
return 1;
}
d = MHD_start_daemon(MHD_USE_THREAD_PER_CONNECTION,
atoi(argv[1]),
NULL,
NULL,
&ahc_echo,
PAGE,
MHD_OPTION_END);
if (d == NULL)
return 1;
(void) getc ();
MHD_stop_daemon(d);
return 0;
}
1.GNU Libmicrohttpd是一个用来在项目中内嵌http服务器的C语言库。 2.特点 (1)C语言库,小而快。 (2)API非常简单,且都是可重入的。 (3)兼容HTTP1.1。 (4)支持4种多线程模型(select、poll、pthread、thread poll)。 (5)跨平台。 (6)生成的二制文件只有32K(不包含TLS/SSL等额外功能)。 3.编译调用 将其添加进项目中
GNU Libmicrohttpd是一个用来在项目中内嵌http服务器的C语言库。这是一款免费软件,并且是GNU项目的一部分。 它具有以下几个鲜明的特点: C语言库,小而快 简易的API,且都是可重入的 支持 HTTP 1.1 可以同时侦听多个端口 四种不同的线程模式(select、poll、pthread、thread pool) 库平台支持 GNU/Linux, FreeBSD, OpenBS
GNU libmicrohttpd 0.9.26 是一个 bugfix 版本,修复了某些平台下的 URL 解析器的初始化问题;如果系统 uptime 小于连接的 timeout 不再移除 SSL 连接。 GNU libmicrohttpd 是一个小型的嵌入式 HTTP 服务器 的 C 类库,支持 HTTP 1.1 可以同时侦听多个端口,简单例子请看这里。
As a small introductory task to get GNUnet to run on small devices I started to cross- compile libmicrohttpd on my desktop computer for a router running OpenWRT. This is not intended as a from scratch
GNU libmicrohttpd 0.9.24 修复了在 IE8 和 Chrome 上处理 POST 数据的参数丢失问题;如果客户端请求连接要关闭则自动设置 Connection: close 头;提供 chunked 编码和 content-length 头;MHD 忽略 content-length 头。 GNU libmicrohttpd 是一个小型的嵌入式 HTTP 服务器 的 C 类库
GNU libmicrohttpd 0.9.29 发布 - 开源中国社区 GNU libmicrohttpd 0.9.29 发布
链接:https://ftp.gnu.org/gnu/libmicrohttpd/ Libmicrohttpd简介 GNU Libmicrohttpd是一个用来在项目中内嵌http服务器的C语言库,它具有以下几个非常鲜明的特点: C语言库,小而快。 API非常简单,且都是可重入的。 兼容HTTP1.1。 支持4种多线程模型(select、poll、pthread、thread poll)。 跨平台
因ubuntu16.04版本中默认安装的版本为0.9.44,无法满足janus中0.9.59的最低版本要求,因此需要自行下载安装。 1. 官网下载 http://www.gnu.org/software/libmicrohttpd/ 下载合适版本 https://ftp.gnu.org/gnu/libmicrohttpd/ 选择0.9.59版本 2. 解压 tar -xzvf libmicroh