Giter VIP home page Giter VIP logo

tippy_http_server's Introduction

README

Project: "Tippy" HTTP/1.1 Server

Brief

Lately I've been on an HTTP (1.1) server writing frenzy, and I decided to try Python 3.x for implementing a toy web server. This is a toy project made only for learning purposes and to show off my skills. Finally, I credit the "HTTP Made Really Easy" guide and RFC 9112 as my references. Feel free to fork, etc.

Supported HTTP Features:

  • Basic message reading:
    • Basic syntax checks are done.
    • Headers such as Host, Content-Length and Content-Type are checked.
  • Persistent or closing connection handling.
  • HEAD and GET methods.
  • Basic cache control headers are supported.

Other Features:

  • Producer-Worker thread pooling for handling multiple connections (WIP)
  • Graceful shutdown (WIP)

Bugs:

  1. On multiple tabs from Firefox, only one worker is providing service although another is also awake. This could be dependent on varying browser behavior on refresh. Edge / Chrome usually restarts a new connection on a random port, but Firefox seems more conservative with starting new connections?

Old Sample Run:

Some cURL Test Commands:

  • curl --verbose -I http://localhost:8080/index.html (HEAD of static resource)
  • curl --verbose -X GET http://localhost:8080/index.html (GET page)
  • curl --verbose -X GET http://localhost:8080/info.html (GET page)
  • curl --verbose -X GET http://localhost:8080/index.html -H "Connection: Close" -H "If-Modified-Since: Mon, 12 Jun 2023 23:59:59 GMT" (GET page with update date check... modify public/index.html to test this.)

Things To Do??

  1. Refactor server code to be cleaner: modular, well-named, etc. (WIP)
  2. Add URL parsing for relative and absolute URLs.
  3. Add threading. (WIP)
  4. Support 100 Continue. (To do...)

Usage:

1a. On a Mac or UNIX system, run ifconfig -a in the terminal and find your IPv4 address under inet. 1b. On Windows, run ipconfig in the shell and find your IPv4 address. 2. Create a config.json file in the project root folder. It should follow this format:

{
   "serveaddr": "localhost",
   "port": 8080,
   "backlog": 4
}
  1. Run python3 src/main.py for Mac, or python src/main.py for Windows within the project root folder.
  2. Make requests with cURL or your browser!

tippy_http_server's People

Contributors

drkwitht avatar

Stargazers

 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.