Skip to content

Instantly share code, notes, and snippets.

@robacarp
Created October 10, 2014 20:57
Show Gist options
  • Select an option

  • Save robacarp/aa0405380e4dc9084c4a to your computer and use it in GitHub Desktop.

Select an option

Save robacarp/aa0405380e4dc9084c4a to your computer and use it in GitHub Desktop.
# Generated with some ruby, some vim love, and some manual hackery:
# #!/bin/env ruby
# require 'mechanize'
# page = Mechanize.new.get('http://httpstatus.es')
# codes = body.search('.status').map do |s|
# {
# code: s.search('a').text.to_i,
# name: s.search('a').first['title'],
# description: s.search('.description').text
# }
# end
#
# clean = -> (s) do
# s.downcase
# .gsub(/[^a-z]/,'_') #remove invalid characters
# .gsub(/apache|webdav|rfc/,'_') #remove words we don't need/want
# .gsub(/_{2,}/,'_') #remove duplicate underscores
# .chomp('_') #remove trailing underscores
# end
#
# codes.each do |code|
# puts <<-RUBY
# def #{clean[code[:name]]}; #{code[:code]}; end
# RUBY
# end
#
# codes.each do |code|
# description = code[:description].gsub(/'/,"\\'")
# puts <<-RUBY
# def #{clean[code[:name]]}; '#{description}'; end
# RUBY
# end
module Status
def continue; 100; end
def switching_protocols; 101; end
def processing; 102; end
def checkpoint; 103; end
def request_uri_too_long; 122; end
def ok; 200; end
def created; 201; end
def accepted; 202; end
def non_authoritative_information_since_http; 203; end
def no_content; 204; end
def reset_content; 205; end
def partial_content; 206; end
def multi_status; 207; end
def already_reported; 208; end
def im_used; 226; end
def multiple_choices; 300; end
def moved_permanently; 301; end
def found; 302; end
def see_other; 303; end
def not_modified; 304; end
def use_proxy_since_http; 305; end
def switch_proxy; 306; end
def temporary_redirect_since_http; 307; end
def permanent_redirect; 308; end
def bad_request; 400; end
def unauthorized; 401; end
def payment_required; 402; end
def forbidden; 403; end
def not_found; 404; end
def method_not_allowed; 405; end
def not_acceptable; 406; end
def proxy_authentication_required; 407; end
def request_timeout; 408; end
def conflict; 409; end
def gone; 410; end
def length_required; 411; end
def precondition_failed; 412; end
def request_entity_too_large; 413; end
def request_uri_too_long; 414; end
def unsupported_media_type; 415; end
def requested_range_not_satisfiable; 416; end
def expectation_failed; 417; end
def im_a_teapot; 418; end
def enhance_your_calm; 420; end
def unprocessable_entity; 422; end
def locked; 423; end
def failed_dependency; 424; end
def upgrade_required; 426; end
def precondition_required; 428; end
def too_many_requests; 429; end
def request_header_fields_too_large; 431; end
def no_response; 444; end
def retry_with; 449; end
def blocked_by_windows_parental_controls; 450; end
def wrong_exchange_server; 451; end
def client_closed_request; 499; end
def internal_server_error; 500; end
def not_implemented; 501; end
def bad_gateway; 502; end
def service_unavailable; 503; end
def gateway_timeout; 504; end
def http_version_not_supported; 505; end
def variant_also_negotiates; 506; end
def insufficient_storage; 507; end
def loop_detected; 508; end
def bandwidth_limit_exceeded_bw_limited_extension; 509; end
def not_extended; 510; end
def network_authentication_required; 511; end
def network_read_timeout_error; 598; end
def network_connect_timeout_error; 599; end
module Description
def continue; 'Client should continue with request'; end
def switching_protocols; 'Server is switching protocols'; end
def processing; 'Server has received and is processing the request'; end
def checkpoint; 'resume aborted PUT or POST requests'; end
def request_uri_too_long; 'URI is longer than a maximum of 2083 characters'; end
def ok; 'standard response for successful HTTP requests'; end
def created; 'request has been fulfilled; new resource created'; end
def accepted; 'request accepted, processing pending'; end
def non_authoritative_information_since_http; 'request processed, information may be from another source'; end
def no_content; 'request processed, no content returned'; end
def reset_content; 'request processed, no content returned, reset document view'; end
def partial_content; 'partial resource return due to request header'; end
def multi_status; 'XML, can contain multiple separate responses'; end
def already_reported; 'results previously returned '; end
def im_used; 'request fulfilled, reponse is instance-manipulations'; end
def multiple_choices; 'multiple options for the resource delivered'; end
def moved_permanently; 'this and all future requests directed to the given URI'; end
def found; 'temporary response to request found via alternative URI'; end
def see_other; 'permanent response to request found via alternative URI'; end
def not_modified; 'resource has not been modified since last requested'; end
def use_proxy_since_http; 'content located elsewhere, retrieve from there'; end
def switch_proxy; 'subsequent requests should use the specified proxy'; end
def temporary_redirect_since_http; 'connect again to different URI as provided'; end
def permanent_redirect; 'connect again to a different URI using the same method'; end
def bad_request; 'request cannot be fulfilled due to bad syntax'; end
def unauthorized; 'authentication is possible but has failed '; end
def payment_required; 'payment required, reserved for future use'; end
def forbidden; 'server refuses to respond to request'; end
def not_found; 'requested resource could not be found'; end
def method_not_allowed; 'request method not supported by that resource'; end
def not_acceptable; 'content not acceptable according to the Accept headers'; end
def proxy_authentication_required; 'client must first authenticate itself with the proxy'; end
def request_timeout; 'server timed out waiting for the request'; end
def conflict; 'request could not be processed because of conflict'; end
def gone; 'resource is no longer available and will not be available again'; end
def length_required; 'request did not specify the length of its content'; end
def precondition_failed; 'server does not meet request preconditions'; end
def request_entity_too_large; 'request is larger than the server is willing or able to process'; end
def request_uri_too_long; 'URI provided was too long for the server to process'; end
def unsupported_media_type; 'server does not support media type'; end
def requested_range_not_satisfiable; 'client has asked for unprovidable portion of the file'; end
def expectation_failed; 'server cannot meet requirements of Expect request-header field'; end
def i_m_a_teapot; 'Im a teapotm a teapot'; end
def enhance_your_calm; 'Twitter rate limiting'; end
def unprocessable_entity; 'request unable to be followed due to semantic errors'; end
def locked; 'resource that is being accessed is locked'; end
def failed_dependency; 'request failed due to failure of a previous request'; end
def upgrade_required; 'client should switch to a different protocol'; end
def precondition_required; 'origin server requires the request to be conditional'; end
def too_many_requests; 'user has sent too many requests in a given amount of time'; end
def request_header_fields_too_large; 'server is unwilling to process the request'; end
def no_response; 'server returns no information and closes the connection'; end
def retry_with; 'request should be retried after performing action'; end
def blocked_by_windows_parental_controls; 'Windows Parental Controls blocking access to webpage'; end
def wrong_exchange_server; 'The server cannot reach the clients mailbox.s mailbox.'; end
def client_closed_request; 'connection closed by client while HTTP server is processing'; end
def internal_server_error; 'generic error message'; end
def not_implemented; 'server does not recognise method or lacks ability to fulfill'; end
def bad_gateway; 'server received an invalid response from upstream server'; end
def service_unavailable; 'server is currently unavailable'; end
def gateway_timeout; 'gateway did not receive response from upstream server'; end
def http_version_not_supported; 'server does not support the HTTP protocol version'; end
def variant_also_negotiates; 'content negotiation for the request results in a circular reference'; end
def insufficient_storage; 'server is unable to store the representation'; end
def loop_detected; 'server detected an infinite loop while processing the request'; end
def bandwidth_limit_exceeded_bw_limited_extension; 'bandwidth limit exceeded'; end
def not_extended; 'further extensions to the request are required'; end
def network_authentication_required; 'client needs to authenticate to gain network access'; end
def network_read_timeout_error; 'network read timeout behind the proxy '; end
def network_connect_timeout_error; 'network connect timeout behind the proxy'; end
end
class DescriptionProxy
class << self
include Description
end
end
def describe
DescriptionProxy
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment