Giter Club home page Giter Club logo

web-server's Introduction

This project is a functional web server built in Java. The server is designed to listen for incoming HTTP requests on a specified port and serve files from a designated document root directory. It supports basic HTTP/1.0 and HTTP/1.1 protocols and handles various file types including HTML, JPG, GIF, and TXT. The server appropriately responds to different requests, handling scenarios such as 200, 400, 403 and 404.

The server operates on a continual loop, persistently listening for incoming connections. Upon accepting a new connection from a client, it initiates a multi-threaded approach, where each connection is handled by a separate thread. This design choice enhances the server’s ability to manage multiple concurrent client requests.

The core functionality of the server includes: • Parsing the HTTP request from the client. • Validating the form of the request, with error responses for malformed requests. • Determining the existence and access permissions of the requested file, responding with appropriate HTTP error codes (such as 404 for Not Found or 403 for Forbidden) when necessary. • Transmitting the contents of the file through socket writing operations if the file exists and is accessible.

The server has its implementation of a heuristic approach to manage persistent connections for HTTP/1.1 protocol. This heuristic determines the duration for which the server keeps a connection open before timing out, based on the current server load. It allows the server to dynamically adjust the timeout period, keeping connections open longer during periods of low activity and closing them sooner under high load to optimize resource usage.

web-server's People

Contributors

awang0712 avatar

Watchers

 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.