你好,游客 登录 注册 搜索
背景:
阅读新闻

GNU libmicrohttpd 0.9.35 发布

[日期:2014-05-03] 来源:oschina.net   作者:Linux [字体:大 中 小]

GNU libmicrohttpd 0.9.35 发布,此版本更新内容如下:

  • Adds MHD_OPTION_HTTPS_MEM_DHPARAMS to allow applications to enable perfect forward secrecy
  • Increases FD_SETSIZE and use of native mutex on W32; makes various improvements to the build system (updated macros, new configure options)
  • Improved header compatibility with MSVC. Adds an MHD_is_feature_supported() function to allow the applications to test for enabled features
  • Removes unescaping in the URI path to better comply with the specification ("+" in the path is no longer converted to a space)
  • Fixes looping issue in handling HTTPS connection resets
  • Switches to the OpenSSL cipher list "HIGH" in libmicrospdy

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;
}

GNU libmicrohttpd 的详细介绍:请点这里
GNU libmicrohttpd 的下载地址:请点这里

本文永久更新链接地址:http://www.linuxidc.com/Linux/2014-04/101137.htm

linux
相关资讯       GNU libmicrohttpd 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款