HTTP Statusses 7XX

Now add even more fun with randomizing HTTP Status 7XX.

A new version for Jersey has been released.

With using getRandom method you can return a randomized HTTP 7XX status (e.g. instead of sever error 500 or on unimplemented API calls )

Get the dependency with

<dependency>
    <groupId>be.redlab.jersey</groupId>
    <artifactId>http-7xx</artifactId>
    <version>1.1</version>
</dependency>

Release Info and tag at github

The new release also removes the rebel.xml file from the resources. Although it’s not in the source control, it was in the released artifact due to building that locally. The release is a bit over time due to my gpg key that was expired, that’s fixed now.

/**
 * Puzzle your users with returning a pseudo random HttpStatus7xx on every call.
 *
 * @return a pseudo randomly chosen HttpStatus7xx
 */
public static HttpStatus7xx getRandom() {
	return HttpStatus7xx.values()[RND.nextInt(MAX_RND)];
}

HTTP Status 7XX

Ever wanted to return obscure HTTP Status codes from your Jersey REST application?

Now you can easily get all HTTP Status codes from the 7XX ranged as proposed by some people at RailsCamp ( see spec ) just grab the status codes from here at github or pull em in as maven dependency with

<dependency>
  <groupId>be.redlab.jersey</groupId>
  <artifactId>http-7xx</artifactId>
  <version>1.0</version>
</dependency>

You can just send it with Jersey’s response like return

Response.status(HttpStatus7xx.A_KITTEN_DIES).build();

I know that Tomcat will not send the reason phrase. By default tomcat does not allow to set custom messages for statusses. To get tomcat to send the custom message you have to add a parameter at startup set

-Dorg.apache.coyote.USE_CUSTOM_STATUS_MSG_IN_HEADER=true

and you will have the status message in your response.

I haven’t tested with other containers yet.

Have fun with 7XX !

%d bloggers like this: