An open API service indexing awesome lists of open source software.

https://github.com/arteam/embedded-http-server

A light and minimalistic HTTP server for Java with zero dependencies and quick startup time
https://github.com/arteam/embedded-http-server

http java unit-testing

Last synced: 3 months ago
JSON representation

A light and minimalistic HTTP server for Java with zero dependencies and quick startup time

Awesome Lists containing this project

README

          

# Embedded HTTP server

`embedded-http-server` is a light and minimalistic Java HTTP server with zero dependencies
and quick startup time.

## Maven

```xml

com.github.arteam
embedded-http-server
1.2

```

## Description

`embedded-http-server` is a thin wrapper around `com.sun.net.HttpServer`. The internal Sun server is
quite fast, provides a Java API for accessing requests/responses and already shipped in
the JDK. Unfortunately, the API is quite confusing, not documented and the server lacks
error reporting. This library tries to solve these issues by providing a nice and functional
API for scripting an HTTP server without a long startup time.

## Application

The primary use case is integration testing of HTTP clients. You often need to fire up an
HTTP server in tests to create a test double for a remote HTTP server. That test double should
ideally be rather fast, otherwise you lose the advantage of the quick turnaround time and
eventually switch to testing on a "live" system. Some people are also opionated about
including huge projects as external dependencies without a specific need and want to avoid
bloating the classpath.

## Advantages

The project is not tied to any external API and can be used with any HTTP client or framework.
You can use it with any HTTP client you like:

* https://openjdk.java.net/groups/net/httpclient/intro.html[Java11 HTTP Client]
* https://hc.apache.org/[Apache HTTP Client],
* https://github.com/square/okhttp[OkHTTP],
* https://jersey.java.net/documentation/latest/client.html[Jersey HTTP Client],
* http://docs.spring.io/spring/docs/4.0.x/javadoc-api/org/springframework/web/client/RestTemplate.html[Spring Rest Template],
* or even with http://docs.oracle.com/javase/8/docs/api/java/net/URLConnection.html[URLConnection].

## Alternatives

If you need a real HTTP server for serving a production worload, you should definitely take a look at

* http://www.eclipse.org/jetty/[Jetty],
* https://tomcat.apache.org/[Tomcat],
* http://undertow.io/[Undertow],
* or http://netty.io/[Netty].