Tech Tip: Utility Method: Convert HTTP Status Code to Text Message
PRODUCT: 4D | VERSION: 12 | PLATFORM: Mac & Win
Published On: December 16, 2011
Here is utility method that can be used to convert an HTTP status code into a text value. This information is based on RFC 2616.
// HTTP status codes and messages are defined in RFC 2616: // https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html C_LONGINT($1;$status_l) C_TEXT($0;$message_t) $status_l:=$1 Case of // Information Codes : ($status_l=100) $message_t:="Continue" : ($status_l=101) $message_t:="Switching Protocols" // Success Codes : ($status_l=200) $message_t:="OK" : ($status_l=201) $message_t:="Created" : ($status_l=202) $message_t:="Accepted" : ($status_l=203) $message_t:="Non-Authoritative Information" : ($status_l=204) $message_t:="No Content" : ($status_l=205) $message_t:="Reset Content" : ($status_l=206) $message_t:="Partial Content" // Redirection Codes : ($status_l=300) $message_t:="Multiple Choices" : ($status_l=301) $message_t:="Moved Permanently" : ($status_l=302) $message_t:="Found" : ($status_l=303) $message_t:="See Other" : ($status_l=304) $message_t:="Not Modified" : ($status_l=305) $message_t:="Use Proxy" : ($status_l=307) $message_t:="Temporary Redirect" // Client Error Codes : ($status_l=400) $message_t:="Bad Request" : ($status_l=401) $message_t:="Unauthorized" : ($status_l=402) $message_t:="Payment Required" : ($status_l=403) $message_t:="Forbidden" : ($status_l=404) $message_t:="Not Found" : ($status_l=405) $message_t:="Method Not Allowed" : ($status_l=406) $message_t:="Not Acceptable" : ($status_l=407) $message_t:="Proxy Authentication Required" : ($status_l=408) $message_t:="Request Timeout" : ($status_l=409) $message_t:="Conflict" : ($status_l=410) $message_t:="Gone" : ($status_l=411) $message_t:="Length Required" : ($status_l=412) $message_t:="Precondition Failed" : ($status_l=413) $message_t:="Request Entity Too Large" : ($status_l=414) $message_t:="Request-URI Too Large" : ($status_l=415) $message_t:="Unsupported Media Type" : ($status_l=416) $message_t:="Requested Range Not Satisfiable" : ($status_l=417) $message_t:="Expectation Failed" // Server Error Codes : ($status_l=500) $message_t:="Internal Server Error" : ($status_l=501) $message_t:="Not Implemented" : ($status_l=502) $message_t:="Bad Gateway" : ($status_l=503) $message_t:="Service Unavailable" : ($status_l=504) $message_t:="Gateway Timeout" : ($status_l=505) $message_t:="HTTP Version not supported" Else $message_t:="Unknown status code." End case $0:=$message_t |