http-stat 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d85b66de2cdfe5d00770c6183a8839f041c18ff8
4
+ data.tar.gz: 8407f159200d5adde0500ab86d512c97820f22e2
5
+ SHA512:
6
+ metadata.gz: c7fc3c2ec64916f81da75e252ff990f5c907be4e88d10ce2b56c002163472be6ed2d642d3f9cdde177fc46f6217a5439710b697e91fc85b2b03c4a92778d16c9
7
+ data.tar.gz: 23641600988eff873834693e9bd382a6af4a46f3ca3577a5f3b8338e81f261d7bcce6336031d9a55f63c7e1b4d8cf957efee6cd642b2eeebf250a8ba871a9769
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in http.gemspec
6
+ gemspec
7
+
8
+ gem 'colorize'
9
+
10
+ gem 'rspec'
11
+ gem 'rspec-command'
@@ -0,0 +1,47 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ http-stat (0.1.1)
5
+ colorize
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ colorize (0.8.1)
11
+ diff-lcs (1.3)
12
+ mixlib-shellout (2.3.2)
13
+ rake (10.5.0)
14
+ rspec (3.7.0)
15
+ rspec-core (~> 3.7.0)
16
+ rspec-expectations (~> 3.7.0)
17
+ rspec-mocks (~> 3.7.0)
18
+ rspec-command (1.0.3)
19
+ mixlib-shellout (~> 2.0)
20
+ rspec (~> 3.2)
21
+ rspec-its (~> 1.2)
22
+ rspec-core (3.7.1)
23
+ rspec-support (~> 3.7.0)
24
+ rspec-expectations (3.7.0)
25
+ diff-lcs (>= 1.2.0, < 2.0)
26
+ rspec-support (~> 3.7.0)
27
+ rspec-its (1.2.0)
28
+ rspec-core (>= 3.0.0)
29
+ rspec-expectations (>= 3.0.0)
30
+ rspec-mocks (3.7.0)
31
+ diff-lcs (>= 1.2.0, < 2.0)
32
+ rspec-support (~> 3.7.0)
33
+ rspec-support (3.7.0)
34
+
35
+ PLATFORMS
36
+ ruby
37
+
38
+ DEPENDENCIES
39
+ bundler (~> 1.16)
40
+ colorize
41
+ http-stat!
42
+ rake (~> 10.0)
43
+ rspec
44
+ rspec-command
45
+
46
+ BUNDLED WITH
47
+ 1.16.1
@@ -0,0 +1,38 @@
1
+ # http-stat :mag:
2
+
3
+ A Ruby command line tool for looking up details of http statuses<br/>
4
+
5
+ ## Installation
6
+
7
+ ```github
8
+ $ gem install http-stat
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ Show a master list of all http statuses:
14
+
15
+ ```github
16
+ $ http-stat -s
17
+ ```
18
+
19
+ Pinpoint a specific status, which will give a short synopsis of it
20
+
21
+ ```github
22
+ $ http-stat -s 200
23
+ 200 OK (Success)
24
+ Standard response for succesful HTTP requests. The actual response will depend on the request method used. In a GET request, the response will contain an entity correspoding to the requested resource.
25
+ ```
26
+
27
+
28
+ `-jp`を末尾につけたら、日本語の詳細は表示されます:
29
+
30
+ ```github
31
+ $ http-stat -s 200 -jp
32
+ 200 OK (Success)
33
+ OK。リクエストは成功し、レスポンスとともに要求に応じた情報が返される。ブラウザでページが正しく表示された場合は、ほとんどがこのステータスコードを返している。
34
+ ```
35
+
36
+ ## Contributing
37
+
38
+ Bug reports and pull requests are welcome on GitHub at https://github.com/gazayas/httpd.
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "http"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "http-stat"
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,34 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "http-stat/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "http-stat"
8
+ spec.version = HttpStat::VERSION
9
+ spec.authors = ["gazayas"]
10
+ spec.email = ["g-zayas@hotmail.com"]
11
+
12
+ spec.summary = %q{A command line tool for looking up the details of http (HyperText Transfer Protocol) statuses}
13
+ spec.homepage = "http://www.github.com/gazayas/http-stat"
14
+
15
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
16
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
17
+ #if spec.respond_to?(:metadata)
18
+ # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
19
+ #else
20
+ # raise "RubyGems 2.0 or newer is required to protect against " \
21
+ # "public gem pushes."
22
+ #end
23
+
24
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
25
+ f.match(%r{^(test|spec|features)/})
26
+ end
27
+ spec.bindir = "bin"
28
+ spec.executables = ["http-stat"] # spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
29
+ spec.require_paths = ["lib"]
30
+
31
+ spec.add_development_dependency "bundler", "~> 1.16"
32
+ spec.add_development_dependency "rake", "~> 10.0"
33
+ spec.add_runtime_dependency "colorize"
34
+ end
@@ -0,0 +1,68 @@
1
+ require "http-stat/version"
2
+ require "http-stat/statuses"
3
+
4
+ require "optparse"
5
+ require "colorize"
6
+
7
+ module HttpStat
8
+ OptionParser.new do |opts|
9
+ opts.banner = "A command line tool for looking up the details of http (HyperText Transfer Protocol) statuses"
10
+ opts.separator ""
11
+ opts.separator "Options:"
12
+
13
+ options = {}
14
+
15
+ opts.on("-s [NUMBER]",
16
+ OptionParser::DecimalInteger,
17
+ "Shows the status with details if a number is selected. If no number, shows a master list of all statuses"
18
+ ) do |i|
19
+
20
+ colorizeAndPrint = Proc.new { |stat|
21
+ stat[:number] = stat[:number].to_s
22
+ case stat[:classification]
23
+ when "Information Response"
24
+ print stat[:number].colorize(:cyan)
25
+ when "Success"
26
+ print stat[:number].colorize(:light_green)
27
+ when "Redirection"
28
+ print stat[:number].colorize(:light_cyan)
29
+ when "Client Error"
30
+ print stat[:number].colorize(:light_red)
31
+ when "Server Error"
32
+ print stat[:number].colorize(:light_yellow)
33
+ end
34
+ }
35
+
36
+ unless i
37
+ Statuses.each do |stat|
38
+ colorizeAndPrint.call(stat)
39
+ print " #{stat[:status]} (#{stat[:classification]})\n"
40
+ end
41
+ else
42
+ stat = Statuses.select{ |hash| i == hash[:number] }
43
+ stat = stat.first
44
+ colorizeAndPrint.call(stat)
45
+
46
+ # TODO: Probably not the best way to "parse" this option
47
+ if ARGV.include?("-jp")
48
+ print " #{stat[:status]} (#{stat[:classification]})\n#{stat[:details_jp]}\n"
49
+ else
50
+ print " #{stat[:status]} (#{stat[:classification]})\n#{stat[:details]}\n"
51
+ end
52
+ end
53
+ end
54
+
55
+ opts.on("-jp", "Shows status details in Japanese (日本語で詳細を表示します。-s [NUMBER]の後に定義。)") do |v|
56
+ options[:jp] = v
57
+ end
58
+
59
+ opts.on_tail("-h", "--help", "Shows this") do |help|
60
+ puts opts
61
+ end
62
+
63
+ opts.on_tail("-v", "--version", "Show version") do
64
+ puts VERSION
65
+ exit
66
+ end
67
+ end.parse!
68
+ end
@@ -0,0 +1,510 @@
1
+ module HttpStat
2
+
3
+ # TODO: detailsにエスケープキーで使われる「\」がないか確認すること
4
+
5
+ Statuses = [
6
+ {
7
+ number: 100,
8
+ status: 'Continue',
9
+ details: 'The server has received the request headers and the client should proceed to send the request body ' +
10
+ '(in case of a request for which a body needs to be sent; for example, a POST request). Sending a large request ' +
11
+ 'body to a server after a request has been rejected for inappropriate headers would be inefficient. To have a ' +
12
+ 'server check the request\'s headers, a client must sent Expect: 100-continue as a header in its initial request ' +
13
+ 'and receive a 100 Continue status code in response before sending the body. The response 417 Expectation Failed ' +
14
+ 'indicates the request should not be continued',
15
+ details_jp: '継続。クライアントはリクエストを継続できる。サーバがリクエストの最初の部分を受け取り、まだ拒否していないことを示す。' +
16
+ '例として、クライアントがExpect: 100-continueヘッダをつけたリクエストを行い、それをサーバが受理した場合に返される。'
17
+ },
18
+ {
19
+ number: 101,
20
+ status: 'switching protocols',
21
+ details: 'The requester has asked the server to switch protocols and the server has agreed to do so',
22
+ details_jp: 'プロトコル切替え。サーバはリクエストを理解し、遂行のためにプロトコルの切替えを要求している。'
23
+ },
24
+ {
25
+ number: 102,
26
+ status: 'Processing',
27
+ details: 'A WebDAV request may contain many sub-requests involving file operations, requiring a long time to ' +
28
+ 'complete the request. This code indicates that the server has received and is processing the request, but ' +
29
+ 'no response is available yet. This prevents the client from timing out and assuming the request was lost',
30
+ details_jp: '処理中。WebDAVの拡張ステータスコード。処理が継続されて行われていることを示す。'
31
+ },
32
+
33
+
34
+ {
35
+ number: 200,
36
+ status: 'OK',
37
+ details: 'Standard response for succesful HTTP requests. The actual response will depend on the request ' +
38
+ 'method used. In a GET request, the response will contain an entity correspoding to the requested resource.',
39
+ details_jp: 'OK。リクエストは成功し、レスポンスとともに要求に応じた情報が返される。' +
40
+ 'ブラウザでページが正しく表示された場合は、ほとんどがこのステータスコードを返している。'
41
+ },
42
+ {
43
+ number: 201,
44
+ status: 'Created',
45
+ details: 'The request has been fulfilled, resulting in the creation of a new resource.',
46
+ details_jp: '作成。リクエストは完了し、新たに作成されたリソースのURIが返される。' +
47
+ '例: PUTメソッドでリソースを作成するリクエストを行ったとき、そのリクエストが完了した場合に返される。'
48
+ },
49
+ {
50
+ number: 202,
51
+ status: 'Accepted',
52
+ details: 'The request has been accepted for processing, but the processing has not been completed. ' +
53
+ 'The request might or might not be eventually acted upon, and may be disallowed when processing occurs. ',
54
+ details_jp: '受理。リクエストは受理されたが、処理は完了していない。' +
55
+ '例: PUTメソッドでリソースを作成するリクエストを行ったとき、サーバがリクエストを受理したものの、リソースの作成が完了' +
56
+ 'していない場合に返される。バッチ処理向け。'
57
+ },
58
+ {
59
+ number: 203,
60
+ status: 'Non-Autoritative Information (since HTTP/1.1)',
61
+ details: 'The server is a transforming proxy (e.g. a Web accelerator) that received a 200 OK from its ' +
62
+ 'origin, but is returning a modified version of the origin\'s response.',
63
+ details_jp: '信頼できない情報。オリジナルのデータではなく、ローカルやプロキシ等からの情報であることを示す。'
64
+ },
65
+ {
66
+ number: 204,
67
+ status: 'No Content',
68
+ details: 'The server successfully processed the request and is not returning any content.',
69
+ details_jp: '内容なし。リクエストを受理したが、返すべきレスポンスエンティティが存在しない場合に返される。' +
70
+ '例: POSTメソッドでフォームの内容を送信したが、ブラウザの画面を更新しない場合に返される。'
71
+ },
72
+ {
73
+ number: 205,
74
+ status: 'Reset Content',
75
+ details: 'The server successfully processed the request, but is not returning any content. Unlike a ' +
76
+ '204 response, this response requires that the requester reset the document view.',
77
+ details_jp: '内容のリセット。リクエストを受理し、ユーザエージェントの画面をリセットする場合に返される。' +
78
+ '例: POSTメソッドでフォームの内容を送信した後、ブラウザの画面を初期状態に戻す場合に返される。'
79
+ },
80
+ {
81
+ number: 206,
82
+ status: 'Partial Content (RFC 7233)',
83
+ details: 'The server is delivering only part of the resource (byte serving) due to a range header sent ' +
84
+ 'by the client. The range header is used by HTTP clients to enable resuming of interrupted downloads, ' +
85
+ 'or split a download into multiple simultaneous streams.',
86
+ details_jp: '部分的内容。部分的GETリクエストを受理したときに、返される。' +
87
+ '例: ダウンロードツール等で分割ダウンロードを行った場合や、レジュームを行った場合に返される。'
88
+ },
89
+ {
90
+ number: 207,
91
+ status: 'Multi-Status (WebDAV; RFC 4918)',
92
+ details: 'The message body that follows is an XML message and can contain a number of separate repsonse ' +
93
+ 'codes, depending on how many sub-requests were made.',
94
+ details_jp: '複数のステータス。WebDAVの拡張ステータスコード。'
95
+ },
96
+ {
97
+ number: 208,
98
+ status: 'Already Reported (WebDAV; RFC 5842)',
99
+ details: 'The members of a DAV binding have already been enumerated in a previous reply to this request, ' +
100
+ 'and are not being included again.',
101
+ details_jp: '既に報告。WebDAVの拡張ステータスコード。'
102
+ },
103
+ {
104
+ number: 226,
105
+ status: 'IM Used',
106
+ details: 'The server has fulfilled a request for the resource, and the response is a representation of ' +
107
+ 'the result of one or more instance-manipulations applied to the current instance.',
108
+ details_jp: 'IM使用。Delta encoding in HTTPの拡張ステータスコード。'
109
+ },
110
+
111
+
112
+ {
113
+ number: 300,
114
+ status: 'Multiple Choices',
115
+ details: 'Indicates multiple options for the resource from which the client may choose (via agent-driven ' +
116
+ 'content negotiation). For example, this code could be used to present multiple video format options, to ' +
117
+ 'list files with different filename extensions, or to suggest word-sense disambiguation.',
118
+ details_jp: '複数の選択。リクエストしたリソースが複数存在し、ユーザやユーザーエージェントに選択肢を提示するときに' +
119
+ '返される。具体例として、W3Cのhttp://www.w3.org/TR/xhtml11/DTD/xhtml11.html'
120
+ },
121
+ {
122
+ number: 301,
123
+ status: 'Moved Permanently',
124
+ details: 'This and all future requests should be directed to the given URI',
125
+ details_jp: '恒久的に移動した。リクエストしたリソースが恒久的に移動されているときに返される。' +
126
+ 'Location:ヘッダに移動先のURLが示されている。例としては、ファイルではなくディレクトリに対応するURLの末尾に/を書かずに' +
127
+ 'アクセスした場合に返される。具体例として、http://www.w3.org/TR'
128
+ },
129
+ {
130
+ number: 302,
131
+ status: 'Found',
132
+ details: 'This is an example of industry practice contradicting the standard. The HTTP/1.0 specification ' +
133
+ '(RFC 1945) required the client to perform a temporary redirect (the original describing phrase was ' +
134
+ '"Moved Temporarily"), but popular browsers implemented 302 with the functionality of a 303 See Other. ' +
135
+ 'Therefore, HTTP/1.1 added status codes 303 and 307 to distinguish between the two behaviours.' +
136
+ 'However, some Web applications and frameworks use the 302 status code as if it were the 303.',
137
+ details_jp: '発見した。リクエストしたリソースが一時的に移動されているときに返される。Location:ヘッダに移動先のURLが示されている。' +
138
+ '元々はMoved Temporarily(一時的に移動した)で、本来はリクエストしたリソースが一時的にそのURLに存在せず、別のURLにある' +
139
+ '場合に使用するステータスコードであった。しかし、例えば掲示板やWikiなどで投稿後にブラウザを他のURLに転送したいときにもこの' +
140
+ 'コードが使用されるようになったため、302はFoundになり、新たに303・307が作成された。'
141
+ },
142
+ {
143
+ number: 303,
144
+ status: 'See Other (since HTTP/1.1)',
145
+ details: 'The response to the request can be found under another URI using a GET method. When received ' +
146
+ 'in response to a POST (or PUT/DELETE), the client should presume that the server has received the data ' +
147
+ 'and should issue a redirect with a separate GET message.',
148
+ details_jp: '他を参照せよ。リクエストに対するレスポンスが他のURLに存在するときに返される。Location:ヘッダに移動先のURLが示されている。' +
149
+ 'リクエストしたリソースは確かにそのURLにあるが、他のリソースをもってレスポンスとするような場合に使用する。' +
150
+ '302の説明で挙げたような、掲示板やWikiなどで投稿後にブラウザを他のURLに転送したいときに使われるべきコードとして導入された。'
151
+ },
152
+ {
153
+ number: 304,
154
+ status: 'Not Modified (RFC 7232)',
155
+ details: 'Indicates that the resource has not been modified since the version specified by the request headers ' +
156
+ 'If-Modified-Since or If-None-Match. In such case, there is no need to retransmit the resource since the client ' +
157
+ 'still has a previously-downloaded copy',
158
+ details_jp: ''
159
+ },
160
+ {
161
+ number: 305,
162
+ status: 'Use Proxy (since HTTP/1.1)',
163
+ details: 'The requested resource is available only through a proxy, the address for which is provided in the ' +
164
+ 'response. Many HTTP clients (such as Mozilla and Internet Explorer) do not correctly handle responses with this ' +
165
+ 'status code, primarily for security reasons.',
166
+ details_jp: 'プロキシを使用せよ。レスポンスのLocation:ヘッダに示されるプロキシを使用してリクエストを行わなければならないことを示す。'
167
+ },
168
+ {
169
+ number: 306,
170
+ status: 'Switch Proxy',
171
+ details: 'No longer used. Originally meant "Subsequent requests should use the specified proxy."',
172
+ details_jp: '将来のために予約されている。ステータスコードは前のバージョンの仕様書では使われていたが、もはや使われておらず、' +
173
+ '将来のために予約されているとされる。検討段階では、「Switch Proxy」というステータスコードが提案されていた。'
174
+ },
175
+ {
176
+ number: 307,
177
+ status: 'Temporary Redirect (since HTTP/1.1)',
178
+ details: 'In this case, the request should be repeated with another URI; however, future requests should still ' +
179
+ 'use the original URI. In contrast to how 302 was historically implemented, the request method is not allowed ' +
180
+ 'to be changed when reissuing the original request. For example, a POST request should be repeated using ' +
181
+ 'another POST request.',
182
+ details_jp: '一時的リダイレクト。リクエストしたリソースは一時的に移動されているときに返される。Location:ヘッダに移動先のURLが示されている。' +
183
+ '302の規格外な使用法が横行したため、302の本来の使用法を改めて定義したもの。'
184
+ },
185
+ {
186
+ number: 308,
187
+ status: 'Permanent Redirect(RFC 7538)',
188
+ details: 'The request and all future requests should be repeated using another URI. 307 and 308 parallel the ' +
189
+ 'behaviors of 302 and 301, but do not allow the HTTP method to change. So, for example, submitting a form to ' +
190
+ 'a permanently redirected resource may continue smoothly.',
191
+ details_jp: '恒久的リダイレクト。'
192
+ },
193
+
194
+
195
+ {
196
+ number: 400,
197
+ status: 'Bad Request',
198
+ details: 'The server cannot or will not process the request due to an apparent client error (e.g., malformed '+
199
+ 'request syntax, too large size, invalid request message framing, or deceptive request routing).',
200
+ details_jp: 'リクエストが不正である。定義されていないメソッドを使うなど、クライアントのリクエストがおかしい場合に返される。'
201
+ },
202
+ {
203
+ number: 401,
204
+ status: 'Unauthorized',
205
+ details: 'Similar to 403 Forbidden, but specifically for use when authentication is required and has failed ' +
206
+ 'or has not yet been provided. The response must include a WWW-Authenticate header field containing a ' +
207
+ 'challenge applicable to the requested resource. See Basic access authentication and Digest access authentication. ' +
208
+ 'semantically means "unauthenticated", i.e. the user does not have the necessary credentials. ' +
209
+ 'Note: Some sites issue HTTP 401 when an IP address is banned from the website (usually the website domain) and ' +
210
+ 'that specific address is refused permission to access a website.',
211
+ details_jp: '認証が必要である。Basic認証やDigest認証などを行うときに使用される。たいていのブラウザはこのステータスを' +
212
+ '受け取ると、認証ダイアログを表示する。'
213
+ },
214
+ {
215
+ number: 402,
216
+ status: 'Payment Required',
217
+ details: 'Reserved for future use. The original intention was that this code might be used as part of some ' +
218
+ 'form of digital cash or micropayment scheme, but that has not happened, and this code is not usually used. ' +
219
+ 'Google Developers API uses this status if a particular developer has exceeded the daily limit on requests.',
220
+ details_jp: '支払いが必要である。現在は実装されておらず、将来のために予約されているとされる。'
221
+ },
222
+ {
223
+ number: 403,
224
+ status: 'Forbidden',
225
+ details: 'The request was a valid request, but the server is refusing to respond to it. The user might be logged ' +
226
+ 'in but does not have the necessary permissions for the resource.',
227
+ details_jp: '禁止されている。リソースにアクセスすることを拒否された。リクエストはしたが処理できないという意味。' +
228
+ 'アクセス権がない場合や、ホストがアクセス禁止処分を受けた場合などに返される。例: 社内(イントラネット)' +
229
+ 'からのみアクセスできるページに社外からアクセスしようとした。'
230
+ },
231
+ {
232
+ number: 404,
233
+ status: 'Not Found',
234
+ details: 'The requested resource could not be found but may be available in the future. Subsequent requests by ' +
235
+ 'the client are permissible.',
236
+ details_jp: '未検出。リソースが見つからなかった。単に、アクセス権がない場合などにも使用される。'
237
+ },
238
+ {
239
+ number: 405,
240
+ status: 'Method Not Allowed',
241
+ details: 'A request method is not supported for the requested resource; for example, a GET request on a form ' +
242
+ 'which requires data to be presented via POST, or a PUT request on a read-only resource.',
243
+ details_jp: '許可されていないメソッド。許可されていないメソッドを使用しようとした。例: POSTメソッドの使用が許されていない' +
244
+ '場所で、POSTメソッドを使用した場合に返される。'
245
+ },
246
+ {
247
+ number: 406,
248
+ status: 'Not Acceptable',
249
+ details: 'The requested resource is capable of generating only content not acceptable according to the Accept ' +
250
+ 'headers sent in the request.',
251
+ details_jp: '受理できない。Accept関連のヘッダに受理できない内容が含まれている場合に返される。例: サーバは英語か日本語しか' +
252
+ '受け付けられないが、リクエストのAccept-Language:ヘッダにzh(中国語)しか含まれていなかった。' +
253
+ '例: サーバはapplication/pdfを送信したかったが、リクエストのAccept:ヘッダにapplication/pdfが含まれていなかった。' +
254
+ '例: サーバはUTF-8の文章を送信したかったが、リクエストのAccept-Charset:ヘッダには、UTF-8が含まれていなかった。'
255
+ },
256
+ {
257
+ number: 407,
258
+ status: 'Proxy Authentication Required (RFC 7235)',
259
+ details: 'The client must first authenticate itself with the proxy.',
260
+ details_jp: 'プロキシ認証が必要である。プロキシの認証が必要な場合に返される。'
261
+ },
262
+ {
263
+ number: 408,
264
+ status: 'Request Time-out',
265
+ details: 'The server timed out waiting for the request. According to HTTP specifications: "The client did ' +
266
+ 'not produce a request within the time that the server was prepared to wait. The client MAY repeat the request ' +
267
+ 'without modifications at any later time."',
268
+ details_jp: 'リクエストタイムアウト。リクエストが時間以内に完了していない場合に返される。'
269
+ },
270
+ {
271
+ number: 409,
272
+ status: 'Conflict',
273
+ details: 'Indicates that the request could not be processed because of conflict in the request, such as an edit ' +
274
+ 'conflict between multiple simultaneous updates.',
275
+ details_jp: '競合。要求は現在のリソースと競合するので完了出来ない。'
276
+ },
277
+ {
278
+ number: 410,
279
+ status: 'Gone',
280
+ details: 'Indicates that the resource requested is no longer available and will not be available again. This ' +
281
+ 'should be used when a resource has been intentionally removed and the resource should be purged. Upon ' +
282
+ 'receiving a 410 status code, the client should not request the resource in the future. Clients such as search ' +
283
+ 'engines should remove the resource from their indices. Most use cases do not require clients and search ' +
284
+ 'engines to purge the resource, and a "404 Not Found" may be used instead.',
285
+ details_jp: '消滅した。リソースは恒久的に移動・消滅した。どこに行ったかもわからない。404 Not Foundと似ているが、' +
286
+ 'こちらは二度と復活しない場合に使われる。ただし、このコードは特別に設定しないと提示できないため、' +
287
+ 'リソースが消滅しても404コードを出すサイトが多い。'
288
+ },
289
+ {
290
+ number: 411,
291
+ status: 'Length Required',
292
+ details: 'The request did not specify the length of its content, which is required by the requested resource.',
293
+ details_jp: '長さが必要。Content-Length ヘッダがないのでサーバがアクセスを拒否した場合に返される。'
294
+ },
295
+ {
296
+ number: 412,
297
+ status: 'Precondition Failed (RFC 7232)',
298
+ details: 'The server does not meet one of the preconditions that the requester put on the request.',
299
+ details_jp: '前提条件で失敗した。前提条件が偽だった場合に返される。' +
300
+ '例: リクエストのIf-Unmodified-Since:ヘッダに書いた時刻より後に更新があった場合に返される。'
301
+ },
302
+ {
303
+ number: 413,
304
+ status: 'Payload Too Large (RFC 7231)',
305
+ details: 'The request is larger than the server is willing or able to process. Previously called ' +
306
+ '"Request Entity Too Large".',
307
+ details_jp: 'ペイロードが大きすぎる。リクエストエンティティがサーバの許容範囲を超えている場合に返す。' +
308
+ '例: アップローダの上限を超えたデータを送信しようとした。RFC 2616以前では、' +
309
+ 'Request Entity Too Large(リクエストエンティティが大きすぎる)と定められていた。'
310
+ },
311
+ {
312
+ number: 414,
313
+ status: 'URI Too Long (RFC 7231)',
314
+ details: 'The URI provided was too long for the server to process. Often the result of too much data being ' +
315
+ 'encoded as a query-string of a GET request, in which case it should be converted to a POST request. ' +
316
+ 'Called "Request-URI Too Long" previously.',
317
+ details_jp: 'URIが大きすぎる。URIが長過ぎるのでサーバが処理を拒否した場合に返す。' +
318
+ '例: 画像データのような大きなデータをGETメソッドで送ろうとし、URIが何10kBにもなった場合に返す' +
319
+ '(上限はサーバに依存する)。RFC 2616以前では、Request-URI Too Long(リクエストURIが大きすぎる)と定められていた。'
320
+ },
321
+ {
322
+ number: 415,
323
+ status: 'Unsupported Media Type',
324
+ details: 'The request entity has a media type which the server or resource does not support. For example, ' +
325
+ 'the client uploads an image as image/svg+xml, but the server requires that images use a different format.',
326
+ details_jp: 'サポートしていないメディアタイプ。指定されたメディアタイプがサーバでサポートされていない場合に返す。'
327
+ },
328
+ {
329
+ number: 416,
330
+ status: 'Range Not Satisfiable (RFC 7233)',
331
+ details: 'The client has asked for a portion of the file (byte serving), but the server cannot supply that ' +
332
+ 'portion. For example, if the client asked for a part of the file that lies beyond the end of the file. ' +
333
+ 'Called "Requested Range Not Satisfiable" previously.',
334
+ details_jp: 'レンジは範囲外にある。実リソースのサイズを超えるデータを要求した。' +
335
+ 'たとえば、リソースのサイズが1024Byteしかないのに、1025Byteを取得しようとした場合などに返す。' +
336
+ 'RFC 2616以前では、Requested Range Not Satisfiable(リクエストしたレンジは範囲外にある)と定められていた。'
337
+ },
338
+ {
339
+ number: 417,
340
+ status: 'Expectation Failed',
341
+ details: 'The server cannot meet the requirements of the Expect request-header field.',
342
+ details_jp: 'Expectヘッダによる拡張が失敗。その拡張はレスポンスできない。またはプロキシサーバは、' +
343
+ '次に到達するサーバがレスポンスできないと判断している。具体例として、Expect:ヘッダに100-continue' +
344
+ '以外の変なものを入れた場合や、そもそもサーバが100 Continueを扱えない場合に返す。'
345
+ },
346
+ {
347
+ number: 418,
348
+ status: 'I\'m a teapot (RFC 2324)',
349
+ details: 'This code was defined in 1998 as one of the traditional IETF April Fools\' jokes, in RFC 2324, ' +
350
+ 'Hyper Text Coffee Pot Control Protocol, and is not expected to be implemented by actual HTTP servers. ' +
351
+ 'The RFC specifies this code should be returned by teapots requested to brew coffee. This HTTP status is ' +
352
+ 'used as an easter egg in some websites, including Google.com.',
353
+ details_jp: '私はティーポット。HTCPCP/1.0の拡張ステータスコード。ティーポットにコーヒーを淹れさせようとして、' +
354
+ '拒否された場合に返すとされる、ジョークのコードである。'
355
+ },
356
+ {
357
+ number: 421,
358
+ status: 'Misdirected Request (RFC 7540)',
359
+ details: 'The request was directed at a server that is not able to produce a response (for example because ' +
360
+ 'a connection reuse).',
361
+ details_jp: '誤ったリクエスト。'
362
+ },
363
+ {
364
+ number: 422,
365
+ status: 'Unprocessable Entity (WebDAV; RFC 4918)',
366
+ details: 'The request was well-formed but was unable to be followed due to semantic errors.',
367
+ details_jp: '処理できないエンティティ。WebDAVの拡張ステータスコード。'
368
+ },
369
+ {
370
+ number: 423,
371
+ status: 'Locked (WebDav; RFC 4918)',
372
+ details: 'The resource that is being accessed is locked.',
373
+ details_jp: 'ロックされている。WebDAVの拡張ステータスコード。リクエストしたリソースがロックされている場合に返す。'
374
+ },
375
+ {
376
+ number: 424,
377
+ status: 'Failed Dependency (WebDAV; RFC 4918)',
378
+ details: 'The request failed due to failure of a previous request (e.g., a PROPATCH).',
379
+ details_jp: '依存関係で失敗。WebDAVの拡張ステータスコード。'
380
+ },
381
+ {
382
+ number: 426,
383
+ status: 'Upgrade Required',
384
+ details: 'The client should switch to a different protocal such as TLS/1.0, given in the Upgrade header field.',
385
+ details_jp: 'アップグレード要求。Upgrading to TLS Within HTTP/1.1の拡張ステータスコード。'
386
+ },
387
+ {
388
+ number: 428,
389
+ status: 'Precondition Required',
390
+ details: 'The origin server requires the request to be conditional. Intended to prevent "the \'lost update\' ' +
391
+ 'problem, where a client GETs a resource\'s state, modifies it, and PUTs it back to the server, when meanwhile ' +
392
+ 'a third party has modified the state on the server, leading to a conflict."',
393
+ details_jp: ''
394
+ },
395
+ {
396
+ number: 429,
397
+ status: 'Too Many Requests',
398
+ details: 'The user has sent too many requests in a given amount of time. Intended for use with rate-limiting schemes.',
399
+ details_jp: ''
400
+ },
401
+ {
402
+ number: 431,
403
+ status: 'Request Header Fields Too Large (RFC 6585)',
404
+ details: 'The user has sent too many requests in a given amount of time. Intended for use with rate-limiting schemes.',
405
+ details_jp: ''
406
+ },
407
+ {
408
+ number: 451,
409
+ status: 'Unavailable For Legal Reasons',
410
+ details: 'A server operator has received a legal demand to deny access to a resource or to a set of resources ' +
411
+ 'that includes the requested resource. The code 451 was chosen as a reference to the novel Fahrenheit 451.',
412
+ details_jp: '法的理由により利用不可。403 Forbiddenから派生したステータスコード。'
413
+ },
414
+
415
+
416
+ {
417
+ number: 500,
418
+ status: 'Internal Server Error',
419
+ details: 'A generic error message, given when an unexpected condition was encountered and no more specific ' +
420
+ 'message is suitable.',
421
+ details_jp: 'サーバ内部エラー。サーバ内部にエラーが発生した場合に返される。例として、CGIとして動作させているプログラム' +
422
+ 'に文法エラーがあったり、設定に誤りがあった場合などに返される。'
423
+ },
424
+ {
425
+ number: 501,
426
+ status: 'Not Implemented',
427
+ details: 'The server either does not recognize the request method, or it lacks the ability to fulfill the ' +
428
+ 'request. Usually this implies future availability (e.g., a new feature of a web-service API).',
429
+ details_jp: '実装されていない。実装されていないメソッドを使用した。例として、WebDAVが実装されていないサーバに' +
430
+ '対してWebDAVで使用するメソッド(MOVEやCOPY)を使用した場合に返される。'
431
+ },
432
+ {
433
+ number: 502,
434
+ status: 'Bad Gateway',
435
+ details: 'The server was acting as a gateway or proxy and received an invalid response from the upstream server.',
436
+ details_jp: '不正なゲートウェイ。ゲートウェイ・プロキシサーバは不正な要求を受け取り、これを拒否した。'
437
+ },
438
+ {
439
+ number: 503,
440
+ status: 'Service Unavailable',
441
+ details: 'The server is currently unavailable (because it is overloaded or down for maintenance). ' +
442
+ 'Generally, this is a temporary state.',
443
+ details_jp: 'サービス利用不可。サービスが一時的に過負荷やメンテナンスで使用不可能である。例として、アクセスが殺到して' +
444
+ '処理不能に陥った場合に返される。'
445
+ },
446
+ {
447
+ number: 504,
448
+ status: 'Gateway Time-out',
449
+ details: 'The server was acting as a gateway or proxy and did not receive a timely response from ' +
450
+ 'the upstream server.',
451
+ details_jp: 'ゲートウェイタイムアウト。ゲートウェイ・プロキシサーバはURIから推測されるサーバからの適切なレスポンスがなく' +
452
+ 'タイムアウトした。'
453
+ },
454
+ {
455
+ number: 505,
456
+ status: 'HTTP Version Not Supported',
457
+ details: 'The server does not support the HTTP protocol version used in the request.',
458
+ details_jp: 'サポートしていないHTTPバージョン。リクエストがサポートされていないHTTPバージョンである場合に返される。'
459
+ },
460
+ {
461
+ number: 506,
462
+ status: 'Variant Also Negotiates (RFC 2295)',
463
+ details: 'Transparent content negotiation for the request results in a circular reference.',
464
+ details_jp: 'Transparent Content Negotiation in HTTPで定義されている拡張ステータスコード。'
465
+ },
466
+ {
467
+ number: 507,
468
+ status: 'Insufficient Storage (WebDAV; RFC 4918)',
469
+ details: 'The server is unable to store the representation needed to complete the request.',
470
+ details_jp: '容量不足。WebDAVの拡張ステータスコード。リクエストを処理するために必要なストレージの容量が足りない場合に返される。'
471
+ },
472
+ {
473
+ number: 508,
474
+ status: 'Loop Detected (WebDAV; RFC 5842)',
475
+ details: 'The server detected an infinite loop while processing the request (sent in lieu of 208 Already Reported).',
476
+ details_jp: 'WebDAVの拡張ステータスコード。'
477
+ },
478
+ {
479
+ number: 510,
480
+ status: 'Not Extended (RFC 2774)',
481
+ details: 'Further extensions to the request are required for the server to fulfill it.',
482
+ details_jp: '拡張できない。An HTTP Extension Frameworkで定義されている拡張ステータスコード。'
483
+ },
484
+ {
485
+ number: 511,
486
+ status: 'Network Authentication Required (RFC 6585)',
487
+ details: 'The client needs to authenticate to gain network access. Intended for use by intercepting proxies ' +
488
+ 'used to control access to the network (e.g., "captive portals" used to require agreement to Terms of ' +
489
+ 'Service before granting full Internet access via a Wi-Fi hotspot).',
490
+ details_jp: ''
491
+ }
492
+ ]
493
+
494
+ # TODO: Add unofficial codes, like 103 Checkpoint
495
+
496
+ # Add classification to all statuses
497
+ Statuses.each do |s|
498
+ if s[:number] < 200
499
+ s[:classification] = 'Information Response'
500
+ elsif s[:number] >= 200 and s[:number] < 300
501
+ s[:classification] = 'Success'
502
+ elsif s[:number] >= 300 and s[:number] < 400
503
+ s[:classification] = 'Redirection'
504
+ elsif s[:number] >= 400 and s[:number] < 500
505
+ s[:classification] = 'Client Error'
506
+ else
507
+ s[:classification] = 'Server Error'
508
+ end
509
+ end
510
+ end
@@ -0,0 +1,3 @@
1
+ module HttpStat
2
+ VERSION = "1.0.0"
3
+ end
metadata ADDED
@@ -0,0 +1,99 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: http-stat
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - gazayas
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-01-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: colorize
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description:
56
+ email:
57
+ - g-zayas@hotmail.com
58
+ executables:
59
+ - http-stat
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".gitignore"
64
+ - Gemfile
65
+ - Gemfile.lock
66
+ - README.md
67
+ - Rakefile
68
+ - bin/console
69
+ - bin/http-stat
70
+ - bin/setup
71
+ - http-stat.gemspec
72
+ - lib/http-stat.rb
73
+ - lib/http-stat/statuses.rb
74
+ - lib/http-stat/version.rb
75
+ homepage: http://www.github.com/gazayas/http-stat
76
+ licenses: []
77
+ metadata: {}
78
+ post_install_message:
79
+ rdoc_options: []
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ requirements: []
93
+ rubyforge_project:
94
+ rubygems_version: 2.5.2
95
+ signing_key:
96
+ specification_version: 4
97
+ summary: A command line tool for looking up the details of http (HyperText Transfer
98
+ Protocol) statuses
99
+ test_files: []