fluid_cli 0.1.8 → 0.2.1

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.
Files changed (199) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +200 -1
  3. data/exe/fluid +12 -17
  4. data/lib/fluid_cli/version.rb +1 -1
  5. data/lib/fluid_cli.rb +4 -57
  6. metadata +14 -274
  7. data/Rakefile +0 -26
  8. data/dev.yml +0 -5
  9. data/lib/fluid_cli/api.rb +0 -141
  10. data/lib/fluid_cli/assets/post_auth_page/index.html.erb +0 -34
  11. data/lib/fluid_cli/assets/post_auth_page/style.css +0 -58
  12. data/lib/fluid_cli/command.rb +0 -55
  13. data/lib/fluid_cli/commands/help.rb +0 -21
  14. data/lib/fluid_cli/commands/login.rb +0 -30
  15. data/lib/fluid_cli/commands/logout.rb +0 -38
  16. data/lib/fluid_cli/commands/switch.rb +0 -23
  17. data/lib/fluid_cli/commands/theme/common/company_helper.rb +0 -15
  18. data/lib/fluid_cli/commands/theme/common/root_helper.rb +0 -95
  19. data/lib/fluid_cli/commands/theme/dev.rb +0 -61
  20. data/lib/fluid_cli/commands/theme/help.rb +0 -21
  21. data/lib/fluid_cli/commands/theme/init.rb +0 -46
  22. data/lib/fluid_cli/commands/theme/pull.rb +0 -68
  23. data/lib/fluid_cli/commands/theme/push.rb +0 -132
  24. data/lib/fluid_cli/commands/theme.rb +0 -23
  25. data/lib/fluid_cli/commands/whoami.rb +0 -23
  26. data/lib/fluid_cli/commands.rb +0 -19
  27. data/lib/fluid_cli/company_switcher.rb +0 -69
  28. data/lib/fluid_cli/context.rb +0 -691
  29. data/lib/fluid_cli/db.rb +0 -114
  30. data/lib/fluid_cli/entry_point.rb +0 -10
  31. data/lib/fluid_cli/environment.rb +0 -32
  32. data/lib/fluid_cli/file_system_listener.rb +0 -29
  33. data/lib/fluid_cli/form.rb +0 -42
  34. data/lib/fluid_cli/git.rb +0 -319
  35. data/lib/fluid_cli/http_request.rb +0 -60
  36. data/lib/fluid_cli/identity_auth/servlet.rb +0 -39
  37. data/lib/fluid_cli/identity_auth.rb +0 -126
  38. data/lib/fluid_cli/options.rb +0 -38
  39. data/lib/fluid_cli/packager.rb +0 -36
  40. data/lib/fluid_cli/theme/dev_server/certificate_manager.rb +0 -79
  41. data/lib/fluid_cli/theme/dev_server/errors.rb +0 -9
  42. data/lib/fluid_cli/theme/dev_server/header_hash.rb +0 -98
  43. data/lib/fluid_cli/theme/dev_server/hooks/file_change_hook.rb +0 -39
  44. data/lib/fluid_cli/theme/dev_server/hot_reload/resources/hot-reload-no-script.html +0 -27
  45. data/lib/fluid_cli/theme/dev_server/hot_reload/resources/hot_reload.js +0 -28
  46. data/lib/fluid_cli/theme/dev_server/hot_reload/resources/sse_client.js +0 -43
  47. data/lib/fluid_cli/theme/dev_server/hot_reload/resources/theme.js +0 -16
  48. data/lib/fluid_cli/theme/dev_server/hot_reload/script_injector.rb +0 -54
  49. data/lib/fluid_cli/theme/dev_server/hot_reload.rb +0 -75
  50. data/lib/fluid_cli/theme/dev_server/local_assets.rb +0 -92
  51. data/lib/fluid_cli/theme/dev_server/proxy.rb +0 -235
  52. data/lib/fluid_cli/theme/dev_server/proxy_param_builder.rb +0 -82
  53. data/lib/fluid_cli/theme/dev_server/reload_mode.rb +0 -34
  54. data/lib/fluid_cli/theme/dev_server/sse.rb +0 -75
  55. data/lib/fluid_cli/theme/dev_server/watcher.rb +0 -57
  56. data/lib/fluid_cli/theme/dev_server/web_server.rb +0 -140
  57. data/lib/fluid_cli/theme/dev_server.rb +0 -293
  58. data/lib/fluid_cli/theme/development_theme.rb +0 -101
  59. data/lib/fluid_cli/theme/file.rb +0 -105
  60. data/lib/fluid_cli/theme/forms/select.rb +0 -33
  61. data/lib/fluid_cli/theme/mime_type.rb +0 -34
  62. data/lib/fluid_cli/theme/presenters/theme_presenter.rb +0 -49
  63. data/lib/fluid_cli/theme/presenters/themes_presenter.rb +0 -31
  64. data/lib/fluid_cli/theme/root.rb +0 -62
  65. data/lib/fluid_cli/theme/syncer/checksums.rb +0 -66
  66. data/lib/fluid_cli/theme/syncer/downloader.rb +0 -54
  67. data/lib/fluid_cli/theme/syncer/error_reporter.rb +0 -45
  68. data/lib/fluid_cli/theme/syncer/merger.rb +0 -53
  69. data/lib/fluid_cli/theme/syncer/operation.rb +0 -58
  70. data/lib/fluid_cli/theme/syncer/standard_reporter.rb +0 -32
  71. data/lib/fluid_cli/theme/syncer/unsupported_script_warning.rb +0 -90
  72. data/lib/fluid_cli/theme/syncer/uploader/forms/apply_to_all.rb +0 -41
  73. data/lib/fluid_cli/theme/syncer/uploader/forms/apply_to_all_form.rb +0 -37
  74. data/lib/fluid_cli/theme/syncer/uploader/forms/base_strategy_form.rb +0 -64
  75. data/lib/fluid_cli/theme/syncer/uploader/forms/select_delete_strategy.rb +0 -29
  76. data/lib/fluid_cli/theme/syncer/uploader/forms/select_update_strategy.rb +0 -30
  77. data/lib/fluid_cli/theme/syncer/uploader/json_delete_handler.rb +0 -49
  78. data/lib/fluid_cli/theme/syncer/uploader/json_update_handler.rb +0 -71
  79. data/lib/fluid_cli/theme/syncer/uploader.rb +0 -105
  80. data/lib/fluid_cli/theme/syncer.rb +0 -492
  81. data/lib/fluid_cli/theme/theme.rb +0 -186
  82. data/lib/fluid_cli/theme/ui/sync_progress_bar.rb +0 -22
  83. data/lib/fluid_cli/thread_pool/job.rb +0 -35
  84. data/lib/fluid_cli/thread_pool.rb +0 -49
  85. data/packaging/homebrew/fluid_cli.base.rb +0 -103
  86. data/vendor/deps/base64/.document +0 -5
  87. data/vendor/deps/base64/.gitignore +0 -9
  88. data/vendor/deps/base64/BSDL +0 -22
  89. data/vendor/deps/base64/COPYING +0 -56
  90. data/vendor/deps/base64/Gemfile +0 -9
  91. data/vendor/deps/base64/LEGAL +0 -60
  92. data/vendor/deps/base64/README.md +0 -48
  93. data/vendor/deps/base64/Rakefile +0 -31
  94. data/vendor/deps/base64/base64.gemspec +0 -28
  95. data/vendor/deps/base64/bin/console +0 -14
  96. data/vendor/deps/base64/bin/setup +0 -8
  97. data/vendor/deps/base64/lib/base64.rb +0 -382
  98. data/vendor/deps/base64/sig/base64.rbs +0 -358
  99. data/vendor/deps/base64/test/base64/test_base64.rb +0 -115
  100. data/vendor/deps/base64/test_sig/test_base64.rb +0 -44
  101. data/vendor/deps/cli-kit/REVISION +0 -1
  102. data/vendor/deps/cli-kit/lib/cli/kit/args/definition.rb +0 -286
  103. data/vendor/deps/cli-kit/lib/cli/kit/args/evaluation.rb +0 -215
  104. data/vendor/deps/cli-kit/lib/cli/kit/args/parser/node.rb +0 -128
  105. data/vendor/deps/cli-kit/lib/cli/kit/args/parser.rb +0 -125
  106. data/vendor/deps/cli-kit/lib/cli/kit/args/tokenizer.rb +0 -130
  107. data/vendor/deps/cli-kit/lib/cli/kit/args.rb +0 -16
  108. data/vendor/deps/cli-kit/lib/cli/kit/base_command.rb +0 -30
  109. data/vendor/deps/cli-kit/lib/cli/kit/command_help.rb +0 -268
  110. data/vendor/deps/cli-kit/lib/cli/kit/command_registry.rb +0 -150
  111. data/vendor/deps/cli-kit/lib/cli/kit/config.rb +0 -137
  112. data/vendor/deps/cli-kit/lib/cli/kit/core_ext.rb +0 -28
  113. data/vendor/deps/cli-kit/lib/cli/kit/error_handler.rb +0 -166
  114. data/vendor/deps/cli-kit/lib/cli/kit/executor.rb +0 -92
  115. data/vendor/deps/cli-kit/lib/cli/kit/ini.rb +0 -91
  116. data/vendor/deps/cli-kit/lib/cli/kit/levenshtein.rb +0 -92
  117. data/vendor/deps/cli-kit/lib/cli/kit/logger.rb +0 -94
  118. data/vendor/deps/cli-kit/lib/cli/kit/opts.rb +0 -248
  119. data/vendor/deps/cli-kit/lib/cli/kit/parse_args.rb +0 -55
  120. data/vendor/deps/cli-kit/lib/cli/kit/resolver.rb +0 -66
  121. data/vendor/deps/cli-kit/lib/cli/kit/support/test_helper.rb +0 -260
  122. data/vendor/deps/cli-kit/lib/cli/kit/support.rb +0 -11
  123. data/vendor/deps/cli-kit/lib/cli/kit/system.rb +0 -290
  124. data/vendor/deps/cli-kit/lib/cli/kit/util.rb +0 -118
  125. data/vendor/deps/cli-kit/lib/cli/kit/version.rb +0 -7
  126. data/vendor/deps/cli-kit/lib/cli/kit.rb +0 -139
  127. data/vendor/deps/cli-ui/REVISION +0 -1
  128. data/vendor/deps/cli-ui/lib/cli/ui/ansi.rb +0 -218
  129. data/vendor/deps/cli-ui/lib/cli/ui/color.rb +0 -101
  130. data/vendor/deps/cli-ui/lib/cli/ui/formatter.rb +0 -219
  131. data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_stack.rb +0 -67
  132. data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_style/box.rb +0 -179
  133. data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_style/bracket.rb +0 -152
  134. data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_style.rb +0 -127
  135. data/vendor/deps/cli-ui/lib/cli/ui/frame.rb +0 -286
  136. data/vendor/deps/cli-ui/lib/cli/ui/glyph.rb +0 -92
  137. data/vendor/deps/cli-ui/lib/cli/ui/os.rb +0 -63
  138. data/vendor/deps/cli-ui/lib/cli/ui/printer.rb +0 -64
  139. data/vendor/deps/cli-ui/lib/cli/ui/progress.rb +0 -132
  140. data/vendor/deps/cli-ui/lib/cli/ui/progress_reporter.rb +0 -209
  141. data/vendor/deps/cli-ui/lib/cli/ui/prompt/interactive_options.rb +0 -583
  142. data/vendor/deps/cli-ui/lib/cli/ui/prompt/options_handler.rb +0 -36
  143. data/vendor/deps/cli-ui/lib/cli/ui/prompt.rb +0 -381
  144. data/vendor/deps/cli-ui/lib/cli/ui/spinner/async.rb +0 -48
  145. data/vendor/deps/cli-ui/lib/cli/ui/spinner/spin_group.rb +0 -602
  146. data/vendor/deps/cli-ui/lib/cli/ui/spinner.rb +0 -79
  147. data/vendor/deps/cli-ui/lib/cli/ui/stdout_router.rb +0 -399
  148. data/vendor/deps/cli-ui/lib/cli/ui/table.rb +0 -83
  149. data/vendor/deps/cli-ui/lib/cli/ui/terminal.rb +0 -55
  150. data/vendor/deps/cli-ui/lib/cli/ui/truncater.rb +0 -106
  151. data/vendor/deps/cli-ui/lib/cli/ui/version.rb +0 -8
  152. data/vendor/deps/cli-ui/lib/cli/ui/widgets/base.rb +0 -46
  153. data/vendor/deps/cli-ui/lib/cli/ui/widgets/status.rb +0 -79
  154. data/vendor/deps/cli-ui/lib/cli/ui/widgets.rb +0 -89
  155. data/vendor/deps/cli-ui/lib/cli/ui/work_queue.rb +0 -142
  156. data/vendor/deps/cli-ui/lib/cli/ui/wrap.rb +0 -61
  157. data/vendor/deps/cli-ui/lib/cli/ui.rb +0 -359
  158. data/vendor/deps/cli-ui/vendor/reentrant_mutex.rb +0 -78
  159. data/vendor/deps/webrick/.gitignore +0 -9
  160. data/vendor/deps/webrick/Gemfile +0 -3
  161. data/vendor/deps/webrick/LICENSE.txt +0 -22
  162. data/vendor/deps/webrick/README.md +0 -61
  163. data/vendor/deps/webrick/Rakefile +0 -10
  164. data/vendor/deps/webrick/lib/webrick/accesslog.rb +0 -157
  165. data/vendor/deps/webrick/lib/webrick/cgi.rb +0 -313
  166. data/vendor/deps/webrick/lib/webrick/compat.rb +0 -36
  167. data/vendor/deps/webrick/lib/webrick/config.rb +0 -158
  168. data/vendor/deps/webrick/lib/webrick/cookie.rb +0 -172
  169. data/vendor/deps/webrick/lib/webrick/htmlutils.rb +0 -30
  170. data/vendor/deps/webrick/lib/webrick/httpauth/authenticator.rb +0 -117
  171. data/vendor/deps/webrick/lib/webrick/httpauth/basicauth.rb +0 -116
  172. data/vendor/deps/webrick/lib/webrick/httpauth/digestauth.rb +0 -395
  173. data/vendor/deps/webrick/lib/webrick/httpauth/htdigest.rb +0 -132
  174. data/vendor/deps/webrick/lib/webrick/httpauth/htgroup.rb +0 -97
  175. data/vendor/deps/webrick/lib/webrick/httpauth/htpasswd.rb +0 -158
  176. data/vendor/deps/webrick/lib/webrick/httpauth/userdb.rb +0 -53
  177. data/vendor/deps/webrick/lib/webrick/httpauth.rb +0 -96
  178. data/vendor/deps/webrick/lib/webrick/httpproxy.rb +0 -354
  179. data/vendor/deps/webrick/lib/webrick/httprequest.rb +0 -636
  180. data/vendor/deps/webrick/lib/webrick/httpresponse.rb +0 -564
  181. data/vendor/deps/webrick/lib/webrick/https.rb +0 -152
  182. data/vendor/deps/webrick/lib/webrick/httpserver.rb +0 -294
  183. data/vendor/deps/webrick/lib/webrick/httpservlet/abstract.rb +0 -152
  184. data/vendor/deps/webrick/lib/webrick/httpservlet/cgi_runner.rb +0 -47
  185. data/vendor/deps/webrick/lib/webrick/httpservlet/cgihandler.rb +0 -126
  186. data/vendor/deps/webrick/lib/webrick/httpservlet/erbhandler.rb +0 -88
  187. data/vendor/deps/webrick/lib/webrick/httpservlet/filehandler.rb +0 -552
  188. data/vendor/deps/webrick/lib/webrick/httpservlet/prochandler.rb +0 -47
  189. data/vendor/deps/webrick/lib/webrick/httpservlet.rb +0 -23
  190. data/vendor/deps/webrick/lib/webrick/httpstatus.rb +0 -194
  191. data/vendor/deps/webrick/lib/webrick/httputils.rb +0 -512
  192. data/vendor/deps/webrick/lib/webrick/httpversion.rb +0 -76
  193. data/vendor/deps/webrick/lib/webrick/log.rb +0 -156
  194. data/vendor/deps/webrick/lib/webrick/server.rb +0 -381
  195. data/vendor/deps/webrick/lib/webrick/ssl.rb +0 -215
  196. data/vendor/deps/webrick/lib/webrick/utils.rb +0 -265
  197. data/vendor/deps/webrick/lib/webrick/version.rb +0 -18
  198. data/vendor/deps/webrick/lib/webrick.rb +0 -232
  199. data/vendor/deps/webrick/webrick.gemspec +0 -74
@@ -1,313 +0,0 @@
1
- # frozen_string_literal: true
2
- #
3
- # cgi.rb -- Yet another CGI library
4
- #
5
- # Author: IPR -- Internet Programming with Ruby -- writers
6
- # Copyright (c) 2003 Internet Programming with Ruby writers. All rights
7
- # reserved.
8
- #
9
- # $Id$
10
-
11
- require_relative "httprequest"
12
- require_relative "httpresponse"
13
- require_relative "config"
14
- require "stringio"
15
-
16
- module WEBrick
17
-
18
- # A CGI library using WEBrick requests and responses.
19
- #
20
- # Example:
21
- #
22
- # class MyCGI < WEBrick::CGI
23
- # def do_GET req, res
24
- # res.body = 'it worked!'
25
- # res.status = 200
26
- # end
27
- # end
28
- #
29
- # MyCGI.new.start
30
-
31
- class CGI
32
-
33
- # The CGI error exception class
34
-
35
- CGIError = Class.new(StandardError)
36
-
37
- ##
38
- # The CGI configuration. This is based on WEBrick::Config::HTTP
39
-
40
- attr_reader :config
41
-
42
- ##
43
- # The CGI logger
44
-
45
- attr_reader :logger
46
-
47
- ##
48
- # Creates a new CGI interface.
49
- #
50
- # The first argument in +args+ is a configuration hash which would update
51
- # WEBrick::Config::HTTP.
52
- #
53
- # Any remaining arguments are stored in the <code>@options</code> instance
54
- # variable for use by a subclass.
55
-
56
- def initialize(*args)
57
- if defined?(MOD_RUBY)
58
- unless ENV.has_key?("GATEWAY_INTERFACE")
59
- Apache.request.setup_cgi_env
60
- end
61
- end
62
- if %r{HTTP/(\d+\.\d+)} =~ ENV["SERVER_PROTOCOL"]
63
- httpv = $1
64
- end
65
- @config = WEBrick::Config::HTTP.dup.update(
66
- :ServerSoftware => ENV["SERVER_SOFTWARE"] || "null",
67
- :HTTPVersion => HTTPVersion.new(httpv || "1.0"),
68
- :RunOnCGI => true, # to detect if it runs on CGI.
69
- :NPH => false # set true to run as NPH script.
70
- )
71
- if config = args.shift
72
- @config.update(config)
73
- end
74
- @config[:Logger] ||= WEBrick::BasicLog.new($stderr)
75
- @logger = @config[:Logger]
76
- @options = args
77
- end
78
-
79
- ##
80
- # Reads +key+ from the configuration
81
-
82
- def [](key)
83
- @config[key]
84
- end
85
-
86
- ##
87
- # Starts the CGI process with the given environment +env+ and standard
88
- # input and output +stdin+ and +stdout+.
89
-
90
- def start(env=ENV, stdin=$stdin, stdout=$stdout)
91
- sock = WEBrick::CGI::Socket.new(@config, env, stdin, stdout)
92
- req = HTTPRequest.new(@config)
93
- res = HTTPResponse.new(@config)
94
- unless @config[:NPH] or defined?(MOD_RUBY)
95
- def res.setup_header
96
- unless @header["status"]
97
- phrase = HTTPStatus::reason_phrase(@status)
98
- @header["status"] = "#{@status} #{phrase}"
99
- end
100
- super
101
- end
102
- def res.status_line
103
- ""
104
- end
105
- end
106
-
107
- begin
108
- req.parse(sock)
109
- req.script_name = (env["SCRIPT_NAME"] || File.expand_path($0)).dup
110
- req.path_info = (env["PATH_INFO"] || "").dup
111
- req.query_string = env["QUERY_STRING"]
112
- req.user = env["REMOTE_USER"]
113
- res.request_method = req.request_method
114
- res.request_uri = req.request_uri
115
- res.request_http_version = req.http_version
116
- res.keep_alive = req.keep_alive?
117
- self.service(req, res)
118
- rescue HTTPStatus::Error => ex
119
- res.set_error(ex)
120
- rescue HTTPStatus::Status => ex
121
- res.status = ex.code
122
- rescue Exception => ex
123
- @logger.error(ex)
124
- res.set_error(ex, true)
125
- ensure
126
- req.fixup
127
- if defined?(MOD_RUBY)
128
- res.setup_header
129
- Apache.request.status_line = "#{res.status} #{res.reason_phrase}"
130
- Apache.request.status = res.status
131
- table = Apache.request.headers_out
132
- res.header.each{|key, val|
133
- case key
134
- when /^content-encoding$/i
135
- Apache::request.content_encoding = val
136
- when /^content-type$/i
137
- Apache::request.content_type = val
138
- else
139
- table[key] = val.to_s
140
- end
141
- }
142
- res.cookies.each{|cookie|
143
- table.add("Set-Cookie", cookie.to_s)
144
- }
145
- Apache.request.send_http_header
146
- res.send_body(sock)
147
- else
148
- res.send_response(sock)
149
- end
150
- end
151
- end
152
-
153
- ##
154
- # Services the request +req+ which will fill in the response +res+. See
155
- # WEBrick::HTTPServlet::AbstractServlet#service for details.
156
-
157
- def service(req, res)
158
- method_name = "do_" + req.request_method.gsub(/-/, "_")
159
- if respond_to?(method_name)
160
- __send__(method_name, req, res)
161
- else
162
- raise HTTPStatus::MethodNotAllowed,
163
- "unsupported method `#{req.request_method}'."
164
- end
165
- end
166
-
167
- ##
168
- # Provides HTTP socket emulation from the CGI environment
169
-
170
- class Socket # :nodoc:
171
- include Enumerable
172
-
173
- private
174
-
175
- def initialize(config, env, stdin, stdout)
176
- @config = config
177
- @env = env
178
- @header_part = StringIO.new
179
- @body_part = stdin
180
- @out_port = stdout
181
- @out_port.binmode
182
-
183
- @server_addr = @env["SERVER_ADDR"] || "0.0.0.0"
184
- @server_name = @env["SERVER_NAME"]
185
- @server_port = @env["SERVER_PORT"]
186
- @remote_addr = @env["REMOTE_ADDR"]
187
- @remote_host = @env["REMOTE_HOST"] || @remote_addr
188
- @remote_port = @env["REMOTE_PORT"] || 0
189
-
190
- begin
191
- @header_part << request_line << CRLF
192
- setup_header
193
- @header_part << CRLF
194
- @header_part.rewind
195
- rescue Exception
196
- raise CGIError, "invalid CGI environment"
197
- end
198
- end
199
-
200
- def request_line
201
- meth = @env["REQUEST_METHOD"] || "GET"
202
- unless url = @env["REQUEST_URI"]
203
- url = (@env["SCRIPT_NAME"] || File.expand_path($0)).dup
204
- url << @env["PATH_INFO"].to_s
205
- url = WEBrick::HTTPUtils.escape_path(url)
206
- if query_string = @env["QUERY_STRING"]
207
- unless query_string.empty?
208
- url << "?" << query_string
209
- end
210
- end
211
- end
212
- # we cannot get real HTTP version of client ;)
213
- httpv = @config[:HTTPVersion]
214
- return "#{meth} #{url} HTTP/#{httpv}"
215
- end
216
-
217
- def setup_header
218
- @env.each{|key, value|
219
- case key
220
- when "CONTENT_TYPE", "CONTENT_LENGTH"
221
- add_header(key.gsub(/_/, "-"), value)
222
- when /^HTTP_(.*)/
223
- add_header($1.gsub(/_/, "-"), value)
224
- end
225
- }
226
- end
227
-
228
- def add_header(hdrname, value)
229
- unless value.empty?
230
- @header_part << hdrname << ": " << value << CRLF
231
- end
232
- end
233
-
234
- def input
235
- @header_part.eof? ? @body_part : @header_part
236
- end
237
-
238
- public
239
-
240
- def peeraddr
241
- [nil, @remote_port, @remote_host, @remote_addr]
242
- end
243
-
244
- def addr
245
- [nil, @server_port, @server_name, @server_addr]
246
- end
247
-
248
- def gets(eol=LF, size=nil)
249
- input.gets(eol, size)
250
- end
251
-
252
- def read(size=nil)
253
- input.read(size)
254
- end
255
-
256
- def each
257
- input.each{|line| yield(line) }
258
- end
259
-
260
- def eof?
261
- input.eof?
262
- end
263
-
264
- def <<(data)
265
- @out_port << data
266
- end
267
-
268
- def write(data)
269
- @out_port.write(data)
270
- end
271
-
272
- def cert
273
- return nil unless defined?(OpenSSL)
274
- if pem = @env["SSL_SERVER_CERT"]
275
- OpenSSL::X509::Certificate.new(pem) unless pem.empty?
276
- end
277
- end
278
-
279
- def peer_cert
280
- return nil unless defined?(OpenSSL)
281
- if pem = @env["SSL_CLIENT_CERT"]
282
- OpenSSL::X509::Certificate.new(pem) unless pem.empty?
283
- end
284
- end
285
-
286
- def peer_cert_chain
287
- return nil unless defined?(OpenSSL)
288
- if @env["SSL_CLIENT_CERT_CHAIN_0"]
289
- keys = @env.keys
290
- certs = keys.sort.collect{|k|
291
- if /^SSL_CLIENT_CERT_CHAIN_\d+$/ =~ k
292
- if pem = @env[k]
293
- OpenSSL::X509::Certificate.new(pem) unless pem.empty?
294
- end
295
- end
296
- }
297
- certs.compact
298
- end
299
- end
300
-
301
- def cipher
302
- return nil unless defined?(OpenSSL)
303
- if cipher = @env["SSL_CIPHER"]
304
- ret = [ cipher ]
305
- ret << @env["SSL_PROTOCOL"]
306
- ret << @env["SSL_CIPHER_USEKEYSIZE"]
307
- ret << @env["SSL_CIPHER_ALGKEYSIZE"]
308
- ret
309
- end
310
- end
311
- end
312
- end
313
- end
@@ -1,36 +0,0 @@
1
- # frozen_string_literal: true
2
- #
3
- # compat.rb -- cross platform compatibility
4
- #
5
- # Author: IPR -- Internet Programming with Ruby -- writers
6
- # Copyright (c) 2002 GOTOU Yuuzou
7
- # Copyright (c) 2002 Internet Programming with Ruby writers. All rights
8
- # reserved.
9
- #
10
- # $IPR: compat.rb,v 1.6 2002/10/01 17:16:32 gotoyuzo Exp $
11
-
12
- ##
13
- # System call error module used by webrick for cross platform compatibility.
14
- #
15
- # EPROTO:: protocol error
16
- # ECONNRESET:: remote host reset the connection request
17
- # ECONNABORTED:: Client sent TCP reset (RST) before server has accepted the
18
- # connection requested by client.
19
- #
20
- module Errno
21
- ##
22
- # Protocol error.
23
-
24
- class EPROTO < SystemCallError; end
25
-
26
- ##
27
- # Remote host reset the connection request.
28
-
29
- class ECONNRESET < SystemCallError; end
30
-
31
- ##
32
- # Client sent TCP reset (RST) before server has accepted the connection
33
- # requested by client.
34
-
35
- class ECONNABORTED < SystemCallError; end
36
- end
@@ -1,158 +0,0 @@
1
- # frozen_string_literal: true
2
- #
3
- # config.rb -- Default configurations.
4
- #
5
- # Author: IPR -- Internet Programming with Ruby -- writers
6
- # Copyright (c) 2000, 2001 TAKAHASHI Masayoshi, GOTOU Yuuzou
7
- # Copyright (c) 2003 Internet Programming with Ruby writers. All rights
8
- # reserved.
9
- #
10
- # $IPR: config.rb,v 1.52 2003/07/22 19:20:42 gotoyuzo Exp $
11
-
12
- require_relative 'version'
13
- require_relative 'httpversion'
14
- require_relative 'httputils'
15
- require_relative 'utils'
16
- require_relative 'log'
17
-
18
- module WEBrick
19
- module Config
20
- LIBDIR = File::dirname(__FILE__) # :nodoc:
21
-
22
- # for GenericServer
23
- General = Hash.new { |hash, key|
24
- case key
25
- when :ServerName
26
- hash[key] = Utils.getservername
27
- else
28
- nil
29
- end
30
- }.update(
31
- :BindAddress => nil, # "0.0.0.0" or "::" or nil
32
- :Port => nil, # users MUST specify this!!
33
- :MaxClients => 100, # maximum number of the concurrent connections
34
- :ServerType => nil, # default: WEBrick::SimpleServer
35
- :Logger => nil, # default: WEBrick::Log.new
36
- :ServerSoftware => "WEBrick/#{WEBrick::VERSION} " +
37
- "(Ruby/#{RUBY_VERSION}/#{RUBY_RELEASE_DATE})",
38
- :TempDir => ENV['TMPDIR']||ENV['TMP']||ENV['TEMP']||'/tmp',
39
- :DoNotListen => false,
40
- :StartCallback => nil,
41
- :StopCallback => nil,
42
- :AcceptCallback => nil,
43
- :DoNotReverseLookup => true,
44
- :ShutdownSocketWithoutClose => false,
45
- )
46
-
47
- # for HTTPServer, HTTPRequest, HTTPResponse ...
48
- HTTP = General.dup.update(
49
- :Port => 80,
50
- :RequestTimeout => 30,
51
- :HTTPVersion => HTTPVersion.new("1.1"),
52
- :AccessLog => nil,
53
- :MimeTypes => HTTPUtils::DefaultMimeTypes,
54
- :DirectoryIndex => ["index.html","index.htm","index.cgi","index.rhtml"],
55
- :DocumentRoot => nil,
56
- :DocumentRootOptions => { :FancyIndexing => true },
57
- :RequestCallback => nil,
58
- :ServerAlias => nil,
59
- :InputBufferSize => 65536, # input buffer size in reading request body
60
- :OutputBufferSize => 65536, # output buffer size in sending File or IO
61
-
62
- # for HTTPProxyServer
63
- :ProxyAuthProc => nil,
64
- :ProxyContentHandler => nil,
65
- :ProxyVia => true,
66
- :ProxyTimeout => true,
67
- :ProxyURI => nil,
68
-
69
- :CGIInterpreter => nil,
70
- :CGIPathEnv => nil,
71
-
72
- # workaround: if Request-URIs contain 8bit chars,
73
- # they should be escaped before calling of URI::parse().
74
- :Escape8bitURI => false
75
- )
76
-
77
- ##
78
- # Default configuration for WEBrick::HTTPServlet::FileHandler
79
- #
80
- # :AcceptableLanguages::
81
- # Array of languages allowed for accept-language. There is no default
82
- # :DirectoryCallback::
83
- # Allows preprocessing of directory requests. There is no default
84
- # callback.
85
- # :FancyIndexing::
86
- # If true, show an index for directories. The default is true.
87
- # :FileCallback::
88
- # Allows preprocessing of file requests. There is no default callback.
89
- # :HandlerCallback::
90
- # Allows preprocessing of requests. There is no default callback.
91
- # :HandlerTable::
92
- # Maps file suffixes to file handlers. DefaultFileHandler is used by
93
- # default but any servlet can be used.
94
- # :NondisclosureName::
95
- # Do not show files matching this array of globs. .ht* and *~ are
96
- # excluded by default.
97
- # :UserDir::
98
- # Directory inside ~user to serve content from for /~user requests.
99
- # Only works if mounted on /. Disabled by default.
100
-
101
- FileHandler = {
102
- :NondisclosureName => [".ht*", "*~"],
103
- :FancyIndexing => false,
104
- :HandlerTable => {},
105
- :HandlerCallback => nil,
106
- :DirectoryCallback => nil,
107
- :FileCallback => nil,
108
- :UserDir => nil, # e.g. "public_html"
109
- :AcceptableLanguages => [] # ["en", "ja", ... ]
110
- }
111
-
112
- ##
113
- # Default configuration for WEBrick::HTTPAuth::BasicAuth
114
- #
115
- # :AutoReloadUserDB:: Reload the user database provided by :UserDB
116
- # automatically?
117
-
118
- BasicAuth = {
119
- :AutoReloadUserDB => true,
120
- }
121
-
122
- ##
123
- # Default configuration for WEBrick::HTTPAuth::DigestAuth.
124
- #
125
- # :Algorithm:: MD5, MD5-sess (default), SHA1, SHA1-sess
126
- # :Domain:: An Array of URIs that define the protected space
127
- # :Qop:: 'auth' for authentication, 'auth-int' for integrity protection or
128
- # both
129
- # :UseOpaque:: Should the server send opaque values to the client? This
130
- # helps prevent replay attacks.
131
- # :CheckNc:: Should the server check the nonce count? This helps the
132
- # server detect replay attacks.
133
- # :UseAuthenticationInfoHeader:: Should the server send an
134
- # AuthenticationInfo header?
135
- # :AutoReloadUserDB:: Reload the user database provided by :UserDB
136
- # automatically?
137
- # :NonceExpirePeriod:: How long should we store used nonces? Default is
138
- # 30 minutes.
139
- # :NonceExpireDelta:: How long is a nonce valid? Default is 1 minute
140
- # :InternetExplorerHack:: Hack which allows Internet Explorer to work.
141
- # :OperaHack:: Hack which allows Opera to work.
142
-
143
- DigestAuth = {
144
- :Algorithm => 'MD5-sess', # or 'MD5'
145
- :Domain => nil, # an array includes domain names.
146
- :Qop => [ 'auth' ], # 'auth' or 'auth-int' or both.
147
- :UseOpaque => true,
148
- :UseNextNonce => false,
149
- :CheckNc => false,
150
- :UseAuthenticationInfoHeader => true,
151
- :AutoReloadUserDB => true,
152
- :NonceExpirePeriod => 30*60,
153
- :NonceExpireDelta => 60,
154
- :InternetExplorerHack => true,
155
- :OperaHack => true,
156
- }
157
- end
158
- end
@@ -1,172 +0,0 @@
1
- # frozen_string_literal: true
2
- #
3
- # cookie.rb -- Cookie class
4
- #
5
- # Author: IPR -- Internet Programming with Ruby -- writers
6
- # Copyright (c) 2000, 2001 TAKAHASHI Masayoshi, GOTOU Yuuzou
7
- # Copyright (c) 2002 Internet Programming with Ruby writers. All rights
8
- # reserved.
9
- #
10
- # $IPR: cookie.rb,v 1.16 2002/09/21 12:23:35 gotoyuzo Exp $
11
-
12
- require 'time'
13
- require_relative 'httputils'
14
-
15
- module WEBrick
16
-
17
- ##
18
- # Processes HTTP cookies
19
-
20
- class Cookie
21
-
22
- ##
23
- # The cookie name
24
-
25
- attr_reader :name
26
-
27
- ##
28
- # The cookie value
29
-
30
- attr_accessor :value
31
-
32
- ##
33
- # The cookie version
34
-
35
- attr_accessor :version
36
-
37
- ##
38
- # The cookie domain
39
- attr_accessor :domain
40
-
41
- ##
42
- # The cookie path
43
-
44
- attr_accessor :path
45
-
46
- ##
47
- # Is this a secure cookie?
48
-
49
- attr_accessor :secure
50
-
51
- ##
52
- # The cookie comment
53
-
54
- attr_accessor :comment
55
-
56
- ##
57
- # The maximum age of the cookie
58
-
59
- attr_accessor :max_age
60
-
61
- #attr_accessor :comment_url, :discard, :port
62
-
63
- ##
64
- # Creates a new cookie with the given +name+ and +value+
65
-
66
- def initialize(name, value)
67
- @name = name
68
- @value = value
69
- @version = 0 # Netscape Cookie
70
-
71
- @domain = @path = @secure = @comment = @max_age =
72
- @expires = @comment_url = @discard = @port = nil
73
- end
74
-
75
- ##
76
- # Sets the cookie expiration to the time +t+. The expiration time may be
77
- # a false value to disable expiration or a Time or HTTP format time string
78
- # to set the expiration date.
79
-
80
- def expires=(t)
81
- @expires = t && (t.is_a?(Time) ? t.httpdate : t.to_s)
82
- end
83
-
84
- ##
85
- # Retrieves the expiration time as a Time
86
-
87
- def expires
88
- @expires && Time.parse(@expires)
89
- end
90
-
91
- ##
92
- # The cookie string suitable for use in an HTTP header
93
-
94
- def to_s
95
- ret = +""
96
- ret << @name << "=" << @value
97
- ret << "; " << "Version=" << @version.to_s if @version > 0
98
- ret << "; " << "Domain=" << @domain if @domain
99
- ret << "; " << "Expires=" << @expires if @expires
100
- ret << "; " << "Max-Age=" << @max_age.to_s if @max_age
101
- ret << "; " << "Comment=" << @comment if @comment
102
- ret << "; " << "Path=" << @path if @path
103
- ret << "; " << "Secure" if @secure
104
- ret
105
- end
106
-
107
- ##
108
- # Parses a Cookie field sent from the user-agent. Returns an array of
109
- # cookies.
110
-
111
- def self.parse(str)
112
- if str
113
- ret = []
114
- cookie = nil
115
- ver = 0
116
- str.split(/;\s+/).each{|x|
117
- key, val = x.split(/=/,2)
118
- val = val ? HTTPUtils::dequote(val) : ""
119
- case key
120
- when "$Version"; ver = val.to_i
121
- when "$Path"; cookie.path = val
122
- when "$Domain"; cookie.domain = val
123
- when "$Port"; cookie.port = val
124
- else
125
- ret << cookie if cookie
126
- cookie = self.new(key, val)
127
- cookie.version = ver
128
- end
129
- }
130
- ret << cookie if cookie
131
- ret
132
- end
133
- end
134
-
135
- ##
136
- # Parses the cookie in +str+
137
-
138
- def self.parse_set_cookie(str)
139
- cookie_elem = str.split(/;/)
140
- first_elem = cookie_elem.shift
141
- first_elem.strip!
142
- key, value = first_elem.split(/=/, 2)
143
- cookie = new(key, HTTPUtils.dequote(value))
144
- cookie_elem.each{|pair|
145
- pair.strip!
146
- key, value = pair.split(/=/, 2)
147
- if value
148
- value = HTTPUtils.dequote(value.strip)
149
- end
150
- case key.downcase
151
- when "domain" then cookie.domain = value
152
- when "path" then cookie.path = value
153
- when "expires" then cookie.expires = value
154
- when "max-age" then cookie.max_age = Integer(value)
155
- when "comment" then cookie.comment = value
156
- when "version" then cookie.version = Integer(value)
157
- when "secure" then cookie.secure = true
158
- end
159
- }
160
- return cookie
161
- end
162
-
163
- ##
164
- # Parses the cookies in +str+
165
-
166
- def self.parse_set_cookies(str)
167
- return str.split(/,(?=[^;,]*=)|,$/).collect{|c|
168
- parse_set_cookie(c)
169
- }
170
- end
171
- end
172
- end
@@ -1,30 +0,0 @@
1
- # frozen_string_literal: true
2
- #--
3
- # htmlutils.rb -- HTMLUtils Module
4
- #
5
- # Author: IPR -- Internet Programming with Ruby -- writers
6
- # Copyright (c) 2000, 2001 TAKAHASHI Masayoshi, GOTOU Yuuzou
7
- # Copyright (c) 2002 Internet Programming with Ruby writers. All rights
8
- # reserved.
9
- #
10
- # $IPR: htmlutils.rb,v 1.7 2002/09/21 12:23:35 gotoyuzo Exp $
11
-
12
- module WEBrick
13
- module HTMLUtils
14
-
15
- ##
16
- # Escapes &, ", > and < in +string+
17
-
18
- def escape(string)
19
- return "" unless string
20
- str = string.b
21
- str.gsub!(/&/n, '&amp;')
22
- str.gsub!(/\"/n, '&quot;')
23
- str.gsub!(/>/n, '&gt;')
24
- str.gsub!(/</n, '&lt;')
25
- str.force_encoding(string.encoding)
26
- end
27
- module_function :escape
28
-
29
- end
30
- end