Giter Club home page Giter Club logo

httpserverexample's Introduction

Just an example of an Http Server

What is an Http Server, anyway?

Well, when you're surfing the web you kinda send packages across the internet and some server receives it, reads it and say "Ok, you're good here" and then send to your destination.

But what does HTTP has to do with it?

HTTP is just a protocol, and like any other protocol, it stands to keep things in order and facilitate communication across clients and servers, using action verbs, such as: get, post, delete, put, patch, and providing a code information with it.

Along with it, HTTP uses headers for requests and responses, providing every information a request accepts for that specific response. It's like you're ordering a pizza and saying your request to the waiter, with the tops and layers you want in your pizza. If the restaurant has it, the waiter will bring it to you, but if it doesn't the waiter will inform that your request couldn't be processed. Either way you get your response.

The image below sums all of it:

image

Nice, but how to do it with Java?

Java has nice objects for http, it also has built-ins autheticators, HTTPS, SSL, communication via websockets and so on. There's a VAST library provided by Sun, introduced to JDK since Java 9 and 11 for better working http clients.

It's not so much productive to work with, and Oracle itself says it's only for educational purposes, but since you grasp on it, you'll come to understand how things works behind the curtains.

For server's implementation you can follow the documentation: https://docs.oracle.com/javase/8/docs/jre/api/net/httpserver/spec/com/sun/net/httpserver/HttpServer.html

And for client's implementation you can also follow the documentation: https://docs.oracle.com/en/java/javase/12/docs/api/java.net.http/java/net/http/HttpClient.html

How to test it?

Well, since it's just an educational project, you can test it with JUnit, just pressing the test button on your IDE.

The project's not finished, and it was for educational purposes, but i'll come back to it soon. :)

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.