com.prolixtech.jaminid

Class Protocol


public class Protocol
extends java.lang.Object

This class captures the essential messages in the HTTP protocol. It behaves as a singleton.

Field Summary

static int
ACCEPTED
static int
BAD_GATEWAY
static int
BAD_REQUEST
static int
CONFLICT
static int
CONTINUE
static int
CREATED
static int
EXPECTATION_FAILED
static int
FORBIDDEN
static int
GATEWAY_TIMEOUT
static int
GONE
static String
HQ_IFMODSINCE
static String
HTTP_VERSION
static int
HTTP_VERSION_NOT_SUPPORTED
static int
INTERNAL_SERVER_ERROR
static int
LENGTH_REQUIRED
static String
MIMEFILE
static int
MOVED_PERMANENTLY
static int
MOVED_TEMPORARILY
static int
MULTIPLE_CHOICE
static int
NONE_ACCEPTABLE
static int
NOT_ALLOWED
static int
NOT_FOUND
static int
NOT_IMPLEMENTED
static int
NOT_MODIFIED
static int
NO_CONTENT
static int
OK
static int
PARTIAL_CONTENT
static int
PAYMENT_REQUIRED
static int
PRECONDITION_FAILED
static int
PROVISIONAL_INFORMATION
static int
PROXY_AUTH_REQUIRED
static int
REQUESTED_RANGE_NOT_SATISFIABLE
static int
REQUEST_ENTITY_TOO_LARGE
static int
REQUEST_TIMEOUT
static int
REQUEST_URI_TOO_LONG
static int
RESET_CONTENT
static int
SEE_OTHER
static int
SERVICE_UNAVAILABLE
static int
SWITCHING
static int
UNAUTHORIZED
static int
UNSUPPORTED_MEDIA_TYPE
static int
USE_PROXY

Method Summary

static Protocol
Instance()
static String
getHeaderResponseStatus(int statusCode)
gets a String description of the status code e.g (200 OK) or (404 FnF)
static String
getMIME(String extension)
MIME type accessor.
static void
makeNewMIME()
Creates a new mime file with the bare basic defaults
static boolean
requestHeaderExists(String requestHeader)
checks if a request header exists in the protocol

Field Details

ACCEPTED

public static final int ACCEPTED
Field Value:
202

BAD_GATEWAY

public static final int BAD_GATEWAY
Field Value:
502

BAD_REQUEST

public static final int BAD_REQUEST
Field Value:
400

CONFLICT

public static final int CONFLICT
Field Value:
409

CONTINUE

public static final int CONTINUE
Field Value:
100

CREATED

public static final int CREATED
Field Value:
201

EXPECTATION_FAILED

public static final int EXPECTATION_FAILED
Field Value:
417

FORBIDDEN

public static final int FORBIDDEN
Field Value:
403

GATEWAY_TIMEOUT

public static final int GATEWAY_TIMEOUT
Field Value:
504

GONE

public static final int GONE
Field Value:
410

HQ_IFMODSINCE

public static final String HQ_IFMODSINCE

HTTP_VERSION

public static final String HTTP_VERSION

HTTP_VERSION_NOT_SUPPORTED

public static final int HTTP_VERSION_NOT_SUPPORTED
Field Value:
505

INTERNAL_SERVER_ERROR

public static final int INTERNAL_SERVER_ERROR
Field Value:
500

LENGTH_REQUIRED

public static final int LENGTH_REQUIRED
Field Value:
411

MIMEFILE

public static final String MIMEFILE

MOVED_PERMANENTLY

public static final int MOVED_PERMANENTLY
Field Value:
301

MOVED_TEMPORARILY

public static final int MOVED_TEMPORARILY
Field Value:
302

MULTIPLE_CHOICE

public static final int MULTIPLE_CHOICE
Field Value:
300

NONE_ACCEPTABLE

public static final int NONE_ACCEPTABLE
Field Value:
406

NOT_ALLOWED

public static final int NOT_ALLOWED
Field Value:
405

NOT_FOUND

public static final int NOT_FOUND
Field Value:
404

NOT_IMPLEMENTED

public static final int NOT_IMPLEMENTED
Field Value:
501

NOT_MODIFIED

public static final int NOT_MODIFIED
Field Value:
304

NO_CONTENT

public static final int NO_CONTENT
Field Value:
204

OK

public static final int OK
Field Value:
200

PARTIAL_CONTENT

public static final int PARTIAL_CONTENT
Field Value:
206

PAYMENT_REQUIRED

public static final int PAYMENT_REQUIRED
Field Value:
402

PRECONDITION_FAILED

public static final int PRECONDITION_FAILED
Field Value:
412

PROVISIONAL_INFORMATION

public static final int PROVISIONAL_INFORMATION
Field Value:
203

PROXY_AUTH_REQUIRED

public static final int PROXY_AUTH_REQUIRED
Field Value:
407

REQUESTED_RANGE_NOT_SATISFIABLE

public static final int REQUESTED_RANGE_NOT_SATISFIABLE
Field Value:
416

REQUEST_ENTITY_TOO_LARGE

public static final int REQUEST_ENTITY_TOO_LARGE
Field Value:
413

REQUEST_TIMEOUT

public static final int REQUEST_TIMEOUT
Field Value:
408

REQUEST_URI_TOO_LONG

public static final int REQUEST_URI_TOO_LONG
Field Value:
414

RESET_CONTENT

public static final int RESET_CONTENT
Field Value:
205

SEE_OTHER

public static final int SEE_OTHER
Field Value:
303

SERVICE_UNAVAILABLE

public static final int SERVICE_UNAVAILABLE
Field Value:
503

SWITCHING

public static final int SWITCHING
Field Value:
101

UNAUTHORIZED

public static final int UNAUTHORIZED
Field Value:
401

UNSUPPORTED_MEDIA_TYPE

public static final int UNSUPPORTED_MEDIA_TYPE
Field Value:
415

USE_PROXY

public static final int USE_PROXY
Field Value:
305

Method Details

Instance

public static Protocol Instance()

getHeaderResponseStatus

public static String getHeaderResponseStatus(int statusCode)
gets a String description of the status code e.g (200 OK) or (404 FnF)
Parameters:
statusCode - the integer status code
Returns:
the String status code

getMIME

public static String getMIME(String extension)
MIME type accessor. By using this, we understand that sometimes the wrong headers might go out for a badly named file (e.g. an mp3 file with extension .txt but this is how all the major HTTP servers do it anyway.
Parameters:
extension - the extension of the file
Returns:
the MIME type of the file according to the extension

makeNewMIME

public static void makeNewMIME()
Creates a new mime file with the bare basic defaults

requestHeaderExists

public static boolean requestHeaderExists(String requestHeader)
checks if a request header exists in the protocol
Parameters:
requestHeader - the request headcer to check
Returns:
true if it exists, false otherwise