Git Product home page Git Product logo

webserver-lib's Introduction

webserver-lib

一个受muduo库启发设计的web服务器,可实现http服务器和tcp服务器。


结构

服务器使用one loop per thread模式,包含两个线程池,其中一个线程池实现IO,另一个线程池实现信息的解码,逻辑运算及编码操作。客户连接会通过Acceptor分发给各个IO线程,IO线程会领用闲置Channel进行数据传输。


特点

  1. 仿servlet接口

    用户只需专注doGet和doPost的实现

  2. 支持session会话

    session会话基于cookie实现。cookie记录SESSION_ID,通过SESSION_ID可索引用户的状态信息

  3. 支持filter

    仿照servlet的filter设计,通过调用chain.doFilter(req, resp)将请求传递至下一级

  4. 更高的内存复用

    读写缓冲区均采用环形队列实现


注意事项

  1. filter根据注册的顺序进行调用
  2. 目前SESSION_ID根据时间进行编码,有较大安全隐患,后续会优化编码方式

已知bug

  1. 同一个用户短时间内发送多次请求可能会造成请求丢失

webserver-lib's People

Contributors

namewudi avatar

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.