working on it ...

Filters

Explore Public Snippets

Sort by

Found 18 snippets matching: http_status

    public by JKCPR  2853  4  6  1

    CUSTOM ERROR PAGE || HTTP STATUS REDIRECT

    Very useful for you to point all your error pages to the same file
    <?php
    // Very useful if you point all your error pages to the same file.
    
    // File; .htaccess
    /*# .htaccess file.
    
    ErrorDocument 404 /error-msg.php
    ErrorDocument 500 /error-msg.php
    ErrorDocument 400 /error-msg.php
    ErrorDocument 401 /error-msg.php
    ErrorDocument 403 /error-msg.php
    # End of file.
    
    // File; error-msg.php 
    */#
    ?>
    <?php
      $HttpStatus = $_SERVER["REDIRECT_STATUS"] ;
      if($HttpStatus==200) {print "Document has been processed and sent to you.";}
      if($HttpStatus==400) {print "Bad HTTP request ";}
      if($HttpStatus==401) {print "Unauthorized - Iinvalid password";}
      if($HttpStatus==403) {print "Forbidden";}
      if($HttpStatus==500) {print "Internal Server Error";}
      if($HttpStatus==418) {print "I'm a teapot! - This is a real value, defined in 1998";}
    
    ?>

    external by Jianfeng Jia  138  0  2  0

    http_status_code

    http_status_code: frequent.txt
    HTTP status codes
    
    HTTP defines a bunch of meaningful status codes that can be returned from your API. These can be leveraged to help the API consumers route their responses accordingly. I've curated a short list of the ones that you definitely should be using:
    
    200 OK - Response to a successful GET, PUT, PATCH or DELETE. Can also be used for a POST that doesn't result in a creation.
    201 Created - Response to a POST that results in a creation. Should be combined with a Location header pointing to the location of the new resource
    204 No Content - Response to a successful request that won't be returning a body (like a DELETE request)
    304 Not Modified - Used when HTTP caching headers are in play
    400 Bad Request - The request is malformed, such as if the body does not parse
    401 Unauthorized - When no or invalid authentication details are provided. Also useful to trigger an auth popup if the API is used from a browser
    403 Forbidden - When authentication succeeded but authenticated user doesn't have access to the resource
    404 Not Found - When a non-existent resource is requested
    405 Method Not Allowed - When an HTTP method is being requested that isn't allowed for the authenticated user
    410 Gone - Indicates that the resource at this end point is no longer available. Useful as a blanket response for old API versions
    415 Unsupported Media Type - If incorrect content type was provided as part of the request
    422 Unprocessable Entity - Used for validation errors
    429 Too Many Requests - When a request is rejected due to rate limiting
    
    
    

    external by lenamuit  72  0  1  0

    HTTP_STATUS_CODES

    HTTP_STATUS_CODES: rack_utils.rb
    HTTP_STATUS_CODES = {
         100 => 'Continue',
         101 => 'Switching Protocols',
         102 => 'Processing',
         200 => 'OK',
         201 => 'Created',
         202 => 'Accepted',
         203 => 'Non-Authoritative Information',
         204 => 'No Content',
         205 => 'Reset Content',
         206 => 'Partial Content',
         207 => 'Multi-Status',
         208 => 'Already Reported',
         226 => 'IM Used',
         300 => 'Multiple Choices',
         301 => 'Moved Permanently',
         302 => 'Found',
         303 => 'See Other',
         304 => 'Not Modified',
         305 => 'Use Proxy',
         306 => 'Reserved',
         307 => 'Temporary Redirect',
         308 => 'Permanent Redirect',
         400 => 'Bad Request',
         401 => 'Unauthorized',
         402 => 'Payment Required',
         403 => 'Forbidden',
         404 => 'Not Found',
         405 => 'Method Not Allowed',
         406 => 'Not Acceptable',
         407 => 'Proxy Authentication Required',
         408 => 'Request Timeout',
         409 => 'Conflict',
         410 => 'Gone',
         411 => 'Length Required',
         412 => 'Precondition Failed',
         413 => 'Request Entity Too Large',
         414 => 'Request-URI Too Long',
         415 => 'Unsupported Media Type',
         416 => 'Requested Range Not Satisfiable',
         417 => 'Expectation Failed',
         422 => 'Unprocessable Entity',
         423 => 'Locked',
         424 => 'Failed Dependency',
         426 => 'Upgrade Required',
         428 => 'Precondition Required',
         429 => 'Too Many Requests',
         431 => 'Request Header Fields Too Large',
         500 => 'Internal Server Error',
         501 => 'Not Implemented',
         502 => 'Bad Gateway',
         503 => 'Service Unavailable',
         504 => 'Gateway Timeout',
         505 => 'HTTP Version Not Supported',
         506 => 'Variant Also Negotiates (Experimental)',
         507 => 'Insufficient Storage',
         508 => 'Loop Detected',
         510 => 'Not Extended',
         511 => 'Network Authentication Required'
       }
    
    
    

    external by Cristian Angulo Nova  45  0  1  0

    HTTP status codes array

    HTTP status codes array: http_status_codes.php
    <?php
    $code = array();
    
    $code['0']   = 'Connection Failed. Please configure Varnish to accept HTTP purge requests.';
    $code['100'] = 'Continue';
    $code['101'] = 'Switching Protocols';
    $code['102'] = 'Processing';
    $code['200'] = 'OK';
    $code['201'] = 'Created';
    $code['202'] = 'Accepted';
    $code['203'] = 'Non-Authoritative Information';
    $code['204'] = 'No Content';
    $code['205'] = 'Reset Content';
    $code['206'] = 'Partial Content';
    $code['207'] = 'Multi-Status';
    $code['300'] = 'Multiple Choices';
    $code['301'] = 'Moved Permanently';
    $code['302'] = 'Found';
    $code['303'] = 'See Other';
    $code['304'] = 'Not Modified';
    $code['305'] = 'Use Proxy';
    $code['306'] = 'Switch Proxy';
    $code['307'] = 'Temporary Redirect';
    $code['400'] = 'Bad Request';
    $code['401'] = 'Unauthorized';
    $code['402'] = 'Payment Required';
    $code['403'] = 'Forbidden';
    $code['404'] = 'Not Found';
    $code['405'] = 'Method Not Allowed';
    $code['406'] = 'Not Acceptable';
    $code['407'] = 'Proxy Authentication Required';
    $code['408'] = 'Request Timeout';
    $code['409'] = 'Conflict';
    $code['410'] = 'Gone';
    $code['411'] = 'Length Required';
    $code['412'] = 'Precondition Failed';
    $code['413'] = 'Request Entity Too Large';
    $code['414'] = 'Request-URI Too Long';
    $code['415'] = 'Unsupported Media Type';
    $code['416'] = 'Requested Range Not Satisfiable';
    $code['417'] = 'Expectation Failed';
    $code['418'] = 'I\'m a teapot';
    $code['422'] = 'Unprocessable Entity';
    $code['423'] = 'Locked';
    $code['424'] = 'Failed Dependency';
    $code['425'] = 'Unordered Collection';
    $code['426'] = 'Upgrade Required';
    $code['449'] = 'Retry With';
    $code['450'] = 'Blocked by Windows Parental Controls';
    $code['500'] = 'Internal Server Error';
    $code['501'] = 'Not Implemented';
    $code['502'] = 'Bad Gateway';
    $code['503'] = 'Service Unavailable';
    $code['504'] = 'Gateway Timeout';
    $code['505'] = 'HTTP Version Not Supported';
    $code['506'] = 'Variant Also Negotiates';
    $code['507'] = 'Insufficient Storage';
    $code['509'] = 'Bandwidth Limit Exceeded';
    $code['510'] = 'Not Extended';
    
    
    

    external by Hadi Badjian  34  0  1  0

    Rails HTTP Status Code to Symbol Map

    Rails HTTP Status Code to Symbol Map: http_status_code_sym.md
    # 1xx Informational
    | Status Code | Status Message      | Symbol               |
    | ----------- | ------------------- | -------------------- |
    | 100         | Continue            | :continue            |
    | 101         | Switching Protocols | :switching_protocols |
    | 102         | Processing          | :processing          |
    
    # 2xx Success
    | Status Code | Status Message                | Symbol                         |
    | ----------- | ----------------------------- | ------------------------------ |
    | 200         | OK                            | :ok                            |
    | 201         | Created                       | :created                       |
    | 202         | Accepted                      | :accepted                      |
    | 203         | Non-Authoritative Information | :non_authoritative_information |
    | 204         | No Content                    | :no_content                    |
    | 205         | Reset Content                 | :reset_content                 |
    | 206         | Partial Content               | :partial_content               |
    | 207         | Multi-Status                  | :multi_status                  |
    | 226         | IM Used                       | :im_used                       |
    
    # 3xx Redirection
    | Status Code | Status Message      | Symbol               |
    | ----------- | ------------------- | -------------------- |
    | 300         | Multiple Choices    | :multiple_choices    |
    | 301         | Moved Permanently   | :moved_permanently   |
    | 302         | Found               | :found               |
    | 303         | See Other           | :see_other           |
    | 304         | Not Modified        | :not_modified        |
    | 305         | Use Proxy           | :use_proxy           |
    | 307         | Temporary Redirect  | :temporary_redirect  |
    
    # 4xx Client Error
    | Status Code | Status Message                  | Symbol                           |
    | ----------- | ------------------------------- | -------------------------------- |
    | 400         | Bad Request                     | :bad_request                     |
    | 401         | Unauthorized                    | :unauthorized                    |
    | 402         | Payment Required                | :payment_required                |
    | 403         | Forbidden                       | :forbidden                       |
    | 404         | Not Found                       | :not_found                       |
    | 405         | Method Not Allowed              | :method_not_allowed              |
    | 406         | Not Acceptable                  | :not_acceptable                  |
    | 407         | Proxy Authentication Required   | :proxy_authentication_required   |
    | 408         | Request Timeout                 | :request_timeout                 |
    | 409         | Conflict                        | :conflict                        |
    | 410         | Gone                            | :gone                            |
    | 411         | Length Required                 | :length_required                 |
    | 412         | Precondition Failed             | :precondition_failed             |
    | 413         | Request Entity Too Large        | :request_entity_too_large        |
    | 414         | Request-URI Too Long            | :request_uri_too_long            |
    | 415         | Unsupported Media Type          | :unsupported_media_type          |
    | 416         | Requested Range Not Satisfiable | :requested_range_not_satisfiable |
    | 417         | Expectation Failed              | :expectation_failed              |
    | 422         | Unprocessable Entity            | :unprocessable_entity            |
    | 423         | Locked                          | :locked                          |
    | 424         | Failed Dependency               | :failed_dependency               |
    | 426         | Upgrade Required                | :upgrade_required                |
    
    # 5xx Server Error
    | Status Code | Status Message             | Symbol                      |
    | ----------- | -------------------------- | --------------------------- |
    | 500         | Internal Server Error      | :internal_server_error      |
    | 501         | Not Implemented            | :not_implemented            |
    | 502         | Bad Gateway                | :bad_gateway                |
    | 503         | Service Unavailable        | :service_unavailable        |
    | 504         | Gateway Timeout            | :gateway_timeout            |
    | 505         | HTTP Version Not Supported | :http_version_not_supported |
    | 507         | Insufficient Storage       | :insufficient_storage       |
    | 510         | Not Extended               | :not_extended               |
    
    
    

    external by ghelobytes  11  0  1  0

    HTTP Response Status Codes

    HTTP Response Status Codes: http_status_codes
    1xx: Information	  	  	  	  	
    Message:			Description:
    100 Continue			The server has received the request headers, and the client should proceed to send the request body
    101 Switching Protocols		The requester has asked the server to switch protocols
    103 Checkpoint			Used in the resumable requests proposal to resume aborted PUT or POST requests
    
    2xx: Successful	   	  	  	
    Message:			Description:
    200 OK				The request is OK (this is the standard response for successful HTTP requests)
    201 Created			The request has been fulfilled, and a new resource is created 
    202 Accepted			The request has been accepted for processing, but the processing has not been completed
    203 Non-Authoritative 		The request has been successfully processed, but is returning information that may be from another source
    	Information	  	  	  	  					
    204 No Content			The request has been successfully processed, but is not returning any content
    205 Reset Content		The request has been successfully processed, but is not returning any content, 
    				and requires that the requester reset the document view
    206 Partial Content		The server is delivering only part of the resource due to a range header sent by the client
    
    3xx: Redirection	  	  	  	  	
    Message:			Description:
    300 Multiple Choices		A link list. The user can select a link and go to that location. Maximum five addresses  
    301 Moved Permanently		The requested page has moved to a new URL 
    302 Found			The requested page has moved temporarily to a new URL 
    303 See Other			The requested page can be found under a different URL
    304 Not Modified		Indicates the requested page has not been modified since last requested
    306 Switch Proxy		No longer used
    307 Temporary Redirect		The requested page has moved temporarily to a new URL
    308 Resume Incomplete		Used in the resumable requests proposal to resume aborted PUT or POST requests
    
    4xx: Client Error	  	  	  	  	
    Message:			Description:
    400 Bad Request			The request cannot be fulfilled due to bad syntax
    401 Unauthorized		The request was a legal request, but the server is refusing to respond to it. 
    				For use when authentication is possible but has failed or not yet been provided
    402 Payment Required		Reserved for future use
    403 Forbidden			The request was a legal request, but the server is refusing to respond to it
    404 Not Found			The requested page could not be found but may be available again in the future
    405 Method Not Allowed		A request was made of a page using a request method not supported by that page
    406 Not Acceptable		The server can only generate a response that is not accepted by the client
    407 Proxy Authentication 	The client must first authenticate itself with the proxy
    	Required	  	  	  	  	
    408 Request Timeout		The server timed out waiting for the request
    409 Conflict			The request could not be completed because of a conflict in the request
    410 Gone			The requested page is no longer available
    411 Length Required		The "Content-Length" is not defined. The server will not accept the request without it 
    412 Precondition Failed		The precondition given in the request evaluated to false by the server
    413 Request Entit		The server will not accept the request, because the request entity is too large
    	Too Large	  	  	  	  	
    414 Request-URI Too Long	The server will not accept the request, because the URL is too long. 
    				Occurs when you convert a POST request to a GET request with a long query information 
    415 Unsupported Media Type	The server will not accept the request, because the media type is not supported 
    416 Requested Range 		The client has asked for a portion of the file, but the server cannot supply that portion
    	Not Satisfiable	  	  	  	  	
    417 Expectation Failed		The server cannot meet the requirements of the Expect request-header field
    
    5xx: Server Error	  	  	  	  	
    Message:			Description:
    500 Internal Server Error	A generic error message, given when no more specific message is suitable
    501 Not Implemented		The server either does not recognize the request method, or it lacks the ability to fulfill the request
    502 Bad Gateway			The server was acting as a gateway or proxy and received an invalid response from the upstream server
    503 Service Unavailable		The server is currently unavailable (overloaded or down)
    504 Gateway Timeout		The server was acting as a gateway or proxy and did not receive a timely response 
    				from the upstream server
    505 HTTP Version		The server does not support the HTTP protocol version used in the request
    	Not Supported	  	  	  	  	
    511 Network Authentication	The client needs to authenticate to gain network access
    	Required	  	  	  	  	
    
    
    

    external by askobara  172  0  2  0

    Make http requests to the given url in loop

    Make http requests to the given url in loop: http_status.sh
    #!/bin/bash
    
    COLOR_NC='\e[0m' # No Color
    COLOR_LIGHT_RED='\e[1;31m'
    COLOR_LIGHT_GREEN='\e[1;32m'
    COLOR_LIGHT_YELLOW='\e[1;33m'
    COLOR_LIGHT_BLUE='\e[1;34m'
    
    usage() {
        echo "$0 [options] url"
        echo ""
        echo "Make http requests to the given url in loop"
        echo ""
        echo "Options:"
        echo "-h, --help            show this help"
        echo "-n, --number          number of itterations. default is 100"
    }
    
    while [ $# -gt 0 ]; do
        case "$1" in
            -h|--help)
                usage
                exit 0
                ;;
            -n|--number)
                shift
                NUMBER=$1
                shift
                ;;
            *)
                break
                ;;
        esac
    done
    
    if [ $# -ne 1 ]; then
        usage
        exit 1
    fi
    
    for i in `seq 1 ${NUMBER:-100}`; do
        RESPONSE=`curl -s -L -o /dev/null -w "%{http_code} %{url_effective} %{time_total}" $1`
        STATUS=${RESPONSE%% *}
        MESSAGE=${RESPONSE#* }
    
        if [ "$STATUS" -ge "500" ]; then
            STATUS_COLOR=${COLOR_LIGHT_RED}
        elif [ "$STATUS" -ge "400" ]; then
            STATUS_COLOR=${COLOR_LIGHT_YELLOW}
        elif [ "$STATUS" -ge "300" ]; then
            STATUS_COLOR=${COLOR_LIGHT_BLUE}
        elif [ "$STATUS" -ge "200" ]; then
            STATUS_COLOR=${COLOR_LIGHT_GREEN}
        fi
    
        echo -e "${STATUS_COLOR}${STATUS}${COLOR_NC} ${MESSAGE}"
    done
    
    
    

    external by Fernando Mohr  161  0  2  0

    How to return specific http status code from Gateway

    How to return specific http status code from Gateway: http_status_code.abap
    RAISE EXCEPTION TYPE /iwbep/cx_mgw_busi_exception
         EXPORTING
           http_status_code  = '404'
    
    
    

    external by WillSquire  115  0  2  0

    Http status - Returns the description of a given http status code.

    Http status - Returns the description of a given http status code.: http_status.php
    /**
     * Returns the description of a given http status code.
     *
     * @param $http_status_code
     * @return string
     */
    private function httpStatus($http_status_code) {
    
        // List of http status code and their corrisponding descriptions
        $http_status_codes = [
            '100' => 'Continue',
            '101' => 'Switching Protocols',
            '200' => 'OK',
            '201' => 'Created',
            '202' => 'Accepted',
            '203' => 'Non-Authoritative Information',
            '204' => 'No Content',
            '205' => 'Reset Content',
            '206' => 'Partial Content',
            '300' => 'Multiple Choices',
            '301' => 'Moved Permanently',
            '302' => 'Moved Temporarily',
            '303' => 'See Other',
            '304' => 'Not Modified',
            '305' => 'Use Proxy',
            '400' => 'Bad Request',
            '401' => 'Unauthorized',
            '402' => 'Payment Required',
            '403' => 'Forbidden',
            '404' => 'Not Found',
            '405' => 'Method Not Allowed',
            '406' => 'Not Acceptable',
            '407' => 'Proxy Authentication Required',
            '408' => 'Request Time-out',
            '409' => 'Conflict',
            '410' => 'Gone',
            '411' => 'Length Required',
            '412' => 'Precondition Failed',
            '413' => 'Request Entity Too Large',
            '414' => 'Request-URI Too Large',
            '415' => 'Unsupported Media Type',
            '500' => 'Internal Server Error',
            '501' => 'Not Implemented',
            '502' => 'Bad Gateway',
            '503' => 'Service Unavailable',
            '504' => 'Gateway Time-out',
            '505' => 'HTTP Version not supported',
        ];
    
        // Return the description of http status code if it exists, else return unknown message
        return (isset($http_status_codes[$http_status_code])) ? $http_status_codes[$http_status_code] : 'Unknown http status code "'.$http_status_code.'"';
    }
    
    

    external by carlzulauf  93  0  1  0

    Custom RSpec matcher for HTTP status codes

    Custom RSpec matcher for HTTP status codes: http_status_matcher.rb
    # Usage: expect(response).to have_status(:unauthorized)
    
    RSpec::Matchers.define(:have_status) do |expected|
      status_code = case expected
                    when Symbol
                      Rack::Utils.status_code(expected)
                    else
                      expected
                    end
    
      match do |actual|
        actual.status == status_code
      end
    
      failure_message_for_should do |actual|
        "expected response status of #{status_code} but got #{actual.status}"
      end
    end
    
    
    
    • Public Snippets
    • Channels Snippets