acl/app/wizard_demo/httpd_upload
2020-08-06 15:42:37 +08:00
..
http_servlet.cpp modify one demo httpd_upload which can be ran on the control of acl master 2020-05-04 20:30:58 +08:00
http_servlet.h Revert "All source code have been changed to use utf8 charset with BOM header!" 2019-07-28 10:31:56 +08:00
httpd_upload_vc2008.sln improving performance and fixed some bugs 2016-02-05 10:10:24 +08:00
httpd_upload_vc2008.vcproj improving performance and fixed some bugs 2016-02-05 10:10:24 +08:00
httpd_upload_vc2010.sln improving performance and fixed some bugs 2016-02-05 10:10:24 +08:00
httpd_upload_vc2010.vcxproj use MD compiling options for all vc projects 2020-08-06 15:42:37 +08:00
httpd_upload_vc2010.vcxproj.filters improving performance and fixed some bugs 2016-02-05 10:10:24 +08:00
httpd_upload_vc2012.sln improving performance and fixed some bugs 2016-02-05 10:10:24 +08:00
httpd_upload_vc2012.vcxproj use MD compiling options for all vc projects 2020-08-06 15:42:37 +08:00
httpd_upload_vc2012.vcxproj.filters improving performance and fixed some bugs 2016-02-05 10:10:24 +08:00
httpd_upload_vc2015.sln compile acl on vc2015 successfully 2016-04-30 11:49:41 +08:00
httpd_upload_vc2015.vcxproj use MD compiling options for all vc projects 2020-08-06 15:42:37 +08:00
httpd_upload_vc2015.vcxproj.filters compile acl on vc2015 successfully 2016-04-30 11:49:41 +08:00
httpd_upload.cf modify one demo httpd_upload which can be ran on the control of acl master 2020-05-04 20:30:58 +08:00
httpd_upload.sln improving performance and fixed some bugs 2016-02-05 10:10:24 +08:00
httpd_upload.vcproj improving performance and fixed some bugs 2016-02-05 10:10:24 +08:00
main.cpp Revert "All source code have been changed to use utf8 charset with BOM header!" 2019-07-28 10:31:56 +08:00
Makefile improving performance and fixed some bugs 2016-02-05 10:10:24 +08:00
Makefile.in change compiling flag "-Wno-extended-offsetof" to "-Wno-invalid-offsetof" for clang 2020-05-19 09:28:57 +08:00
master_service.cpp modify one demo httpd_upload which can be ran on the control of acl master 2020-05-04 20:30:58 +08:00
master_service.h modify one demo httpd_upload which can be ran on the control of acl master 2020-05-04 20:30:58 +08:00
README.md modify README.md of httpd_upload sample 2019-07-24 23:02:10 +08:00
stdafx.cpp Revert "All source code have been changed to use utf8 charset with BOM header!" 2019-07-28 10:31:56 +08:00
stdafx.h modify one demo httpd_upload which can be ran on the control of acl master 2020-05-04 20:30:58 +08:00
upload.html add lost file for one demo httpd_upload 2020-05-03 22:45:27 +08:00
valgrind.sh improving performance and fixed some bugs 2016-02-05 10:10:24 +08:00

通过 http 协议上传文件

概述

本例子使用 acl 库的 HTTP 库及服务器框架编写,其中服务器模型采用 acl 中基于 IO 事件的线程池模型,该服务模型既可以编写出完全非阻塞服务(通常编写时需要注意一些细节),也可以编写完全阻塞服务或者半非阻塞服务。得益于 IO 事件引擎,当客户端连接空闲时,该连接不会占用任何线程,而是被置入 IO 事件集合中,只有当该连接有数据可读时,服务框架才会将一个线程与该连接绑定。
本示例是一个半非阻塞服务模型,当框架读取 HTTP 客户端请求头时是阻塞的,而在读取 HTTP 客户端上传的 MIME 数据体时是非阻塞的,这样做是有好处的,当用户上传的文件比较大时,可能会耗费较长时间,如果使一个线程与该客户端连接长期绑定,则有可能会耗尽线程池中的线程资源。本示例中,因为读 HTTP 数据体过程是非阻塞的,意味着当连接“暂时”没有数据时,线程便会与该 HTTP 连接“解绑”而被“归还”至线程池中,成为空闲线程,当该连接又有新数据到达时线程池中便会有线程被选定来处理该连接上传的数据。这样,线程池中的宝贵的线程资源基本达到了按需使用的目的,仅需少量线程便可以处理大量的 HTTP 并发请求。