Git Product home page Git Product logo

httpserver's Introduction

HTTP Server

This Http Server is a learning project, it is not maintained, so use it on your own risk.

Basic functionality:

  • Server parses and validates incoming message according to RFC2616 and allows to send back a response.
  • Server is multi-threaded.
  • Server understands a different charset of incoming message body and by default uses ISO-8859-1 for all other operations, meaning that with default settings all files must be stored in ISO-8859-1 to use the standard file system handler. However, this behavior is easily changed by modifying bodyCharset field of response in a custom handler or modifying FileSystemHandler class.
  • Server correctly parses parameters of a GET request and body of a POST request sent together with application/x-www-form-urlencoded Content-Type.
  • Server allows to generate response using multiple handlers that are executed in the order they are registered at and only if specified for each handler regular expression matches the request URI.
  • Server is coming with a simple file system handler that allows to get text/html files from some path and navigate through this path using directory listings.
  • Currently only GET, HEAD and POST methods are marked as implemented in default configuration, however handling other request types can be implemented by adding custom handlers.

Project is done in Java 8.

Run core.Server.main() and navigate to http://localhost:8080/ to see a demo.

P.S. Pay attention to core.Response.setBody(). It automatically sets the Content-Length header. In addition, it should be used in case of HEAD requests in the absolutely same manner as for GET requests. It automatically cuts body and leaves all the headers untouched. It is done to make sure that headers of responses sent to GET and HEAD requests are identical as specified in RFC2616.

httpserver's People

Contributors

dmitrie 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.