FANDOM


This function returns the status message associated with a given HTTP response code.

NOTE: If you use XMLHttpRequest instead, you can just check the statusText property after the request is complete.


Usage:

var url = new URL();
url.fetch('http://www.yahoo.com');
log('The response from Yahoo is: ' + httpResponseMessage(url.response));

function httpResponseMessage(response) {
	var strReturn;
	switch (response) {
		case 100: strReturn = 'Continue'; break;
		case 101: strReturn = 'Switching Protocols'; break;
		case 200: strReturn = 'OK'; break;
		case 201: strReturn = 'Created'; break;
		case 202: strReturn = 'Accepted'; break;
		case 203: strReturn = 'Authoritative Information'; break;
		case 204: strReturn = 'No Content'; break;
		case 205: strReturn = 'Reset Content'; break;
		case 206: strReturn = 'Partial Content'; break;
		case 300: strReturn = 'Multiple Choices'; break;
		case 301: strReturn = 'Moved Permanently'; break;
		case 302: strReturn = 'Moved Temporarily'; break;
		case 303: strReturn = 'See Other'; break;
		case 304: strReturn = 'Not Modified'; break;
		case 305: strReturn = 'Use Proxy'; break;
		case 400: strReturn = 'Bad Request'; break;
		case 401: strReturn = 'Unauthorized'; break;
		case 402: strReturn = 'Payment Required'; break;
		case 403: strReturn = 'Forbidden'; break;
		case 404: strReturn = 'Not Found'; break;
		case 405: strReturn = 'Method Not Allowed'; break;
		case 406: strReturn = 'Not Acceptable'; break;
		case 407: strReturn = 'Proxy Authentication Required'; break;
		case 408: strReturn = 'Request Time - Out'; break;
		case 409: strReturn = 'Conflict'; break;
		case 410: strReturn = 'Gone'; break;
		case 411: strReturn = 'Length Required'; break;
		case 412: strReturn = 'Precondition Failed'; break;
		case 413: strReturn = 'Request Entity Too Large'; break;
		case 414: strReturn = 'Request-URL Too Large'; break;
		case 415: strReturn = 'Unsupported Media Type'; break;
		case 500: strReturn = 'Server Error'; break;
		case 501: strReturn = 'Not Implemented'; break;
		case 502: strReturn = 'Bad Gateway'; break;
		case 503: strReturn = 'Out of Resources'; break;
		case 504: strReturn = 'Gateway Time - Out'; break;
		case 505: strReturn = 'HTTP Not Version'; break;
		default:  strReturn = 'Unknown'; break;
	}
	return strReturn;
}

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.