What is it

reasonphrase is a library that provides a lookup from an HTTP Status Code (like 200) to an HTTP Reason Phrase (like OK).

Reason phrases are a mostly unused part of the HTTP protocol but, if you need to pick one anyway, you might as well pick a standard one.

Why use it

In most situations, your web server will automatically pick a reason phrase based on the status code of a response.

A notable exception to this is Microhttp, which exposes the reason phrase directly in its Response record.

So if you are using Microhttp, or some other minimal server, then this library will be of use.

Getting Started

import org.microhttp.EventLoop;
import org.microhttp.Response;
import org.microhttp.Header;

import dev.mccue.reasonphrase.ReasonPhrase;

void main() throws Exception {
    var eventLoop = new EventLoop((request, callback) -> {
        callback.accept(new Response(
            List.of(new Header("Content-Type", "text/plain")),
            "Hello, world".getBytes()


<- Index