Coder Social home page Coder Social logo

java-http's Introduction

java-http

Java implementation of an HTTP server without using the java.net.http package.

Java-HTTP was created as a learning exercise to more fully understand the HTTP protocol. The goal is to have a fully functional HTTP implementation that can serve static files as well as expose an API that servers JSON data.

Current Features

  • API data is stored on a PostgreSQL database
  • Support for hosting and serving files. (HTML)
  • Support for querying data from an API.
  • Get requests on /api/members
    • Support for parameters (name, role, age, name&age)
  • Post requests on /api/members
    • Submit with a json user object body

Details

  • Uses TCP sockets
  • Processes responses and requests manually via text manipulations

Usage

  1. Build the jar
    • The jar can either be a regular jar or a "fat jar".
      • The "fat jar" contains all of the dependencies along with the server.
    • gradle build or gradle shadowJar
  2. Create a directory for static files named HTML
    • Inside the HTML file you are to place all of your different website pages
      • Note) You must have a file named 404.html that will be served when user tries to access and invalid path.
    • The directory should be on the same level as the JAR file
  3. Start the server by running the jar file. You must enter the port the server should listen on as a command line argument.
    • java -jar "java-http".jar 8080

Goals

  • Multithreaded server implementation
  • Process requests and send a response
  • Serve JSON responses to specific queries
  • Serve html pages
  • GZIP before sending data files
  • Save and load data from an SQL database
  • Implement a connection pool for SQL connections.
  • Create configuration file to change certain settings
    • Ability to specify the static files folder
  • Load images
    • This should fix the /favicon.ico failed response
  • Load external css
  • Handle requests according to their HTTP method
  • Add support for other file types.
    • Right now the html file extension is hard coded. This will let me load javascript files from a PWA

java-http's People

Contributors

evan-buss avatar

Watchers

James Cloos avatar  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.