itsi-server 0.2.10 → 0.2.11

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1299ba07e4b4de522049dbf9df9c8948810c0b10f0a82da2f79585d66f803a51
4
- data.tar.gz: 1f6d3ed4821cb0d8652a7659ea9ab6d60643901b307f7e925e818b69fbc5db2c
3
+ metadata.gz: fb707c4c3974d9d6898c48c24f707931d701a9d06a6f8c921f1ef0bdbf32d372
4
+ data.tar.gz: 9bb6bbecd4f4e292b2696a185bff4ff78af30f21f76aaca328df07b27928d9a0
5
5
  SHA512:
6
- metadata.gz: ff5e1d66975a9406fb832e6a742679cc018507223078fac096776fd51324def81a022db3b1324456fa86f2b36f92ce7b79f4cce05c93567e48b25fc02a1ff25d
7
- data.tar.gz: bd898dedfdfa333c5eb7e69d55883585218bcc7ed34c6318b33fd1cf9cf9d66fdb44b4fdeab7f5c87c8ebba3937574545fbc1ba1955e78227f2334fb8acbea77
6
+ metadata.gz: 9c37e1ecca3741c856714ce86f2e7865693de22c5add1eef2d93697c894b6d7d50b9e9bb115f637affd61565f77f922c586db4bd7975911fb78c7ac4f4266330
7
+ data.tar.gz: fcc796258023503fca0baadfe45e71ddd84210f51a3db5d13b143d94e89b538b15eab74b82c496ad42adaf28787627f27d967724a4fecce0cd7b41126df70bca
data/Cargo.lock CHANGED
@@ -1644,7 +1644,7 @@ checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c"
1644
1644
 
1645
1645
  [[package]]
1646
1646
  name = "itsi-server"
1647
- version = "0.2.10"
1647
+ version = "0.2.11"
1648
1648
  dependencies = [
1649
1649
  "argon2",
1650
1650
  "async-channel",
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "itsi-scheduler"
3
- version = "0.2.10"
3
+ version = "0.2.11"
4
4
  edition = "2021"
5
5
  authors = ["Wouter Coppieters <wc@pico.net.nz>"]
6
6
  license = "MIT"
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "itsi-server"
3
- version = "0.2.10"
3
+ version = "0.2.11"
4
4
  edition = "2021"
5
5
  authors = ["Wouter Coppieters <wc@pico.net.nz>"]
6
6
  license = "MIT"
@@ -86,6 +86,8 @@ fn init(ruby: &Ruby) -> Result<()> {
86
86
  response.define_method("<<", method!(ItsiHttpResponse::send_frame, 1))?;
87
87
  response.define_method("write", method!(ItsiHttpResponse::send_frame, 1))?;
88
88
  response.define_method("read", method!(ItsiHttpResponse::recv_frame, 0))?;
89
+ response.define_method("flush", method!(ItsiHttpResponse::flush, 0))?;
90
+ response.define_method("closed?", method!(ItsiHttpResponse::is_closed, 0))?;
89
91
  response.define_method(
90
92
  "send_and_close",
91
93
  method!(ItsiHttpResponse::send_and_close, 1),
@@ -272,6 +272,14 @@ impl ItsiHttpResponse {
272
272
  // not implemented
273
273
  }
274
274
 
275
+ pub fn flush(&self) {
276
+ // no-op
277
+ }
278
+
279
+ pub fn is_closed(&self) -> bool {
280
+ self.data.response_writer.write().is_none()
281
+ }
282
+
275
283
  pub fn send_and_close(&self, frame: Bytes) -> MagnusResult<()> {
276
284
  let result = self.send_frame_into(ByteFrame::End(frame), &self.data.response_writer);
277
285
  self.data.response_writer.write().take();
@@ -11,7 +11,8 @@ module Itsi
11
11
  include ResponseStatusShortcodes
12
12
  attr_accessor :hijacked
13
13
 
14
- EMPTY_IO = StringIO.new("")
14
+ EMPTY_IO = StringIO.new("").tap { |io| io.set_encoding(Encoding::ASCII_8BIT) }
15
+
15
16
  RACK_HEADER_MAP = StandardHeaders::ALL.map do |header|
16
17
  rack_form = if header == "content-type"
17
18
  "CONTENT_TYPE"
@@ -49,9 +50,7 @@ module Itsi
49
50
  "rack.version" => nil,
50
51
  "rack.url_scheme" => "",
51
52
  "rack.input" => "",
52
- "rack.hijack" => "",
53
- "CONTENT_TYPE" => nil,
54
- "CONTENT_LENGTH" => nil
53
+ "rack.hijack" => ""
55
54
  }.freeze
56
55
 
57
56
  def to_rack_env
@@ -75,20 +74,20 @@ module Itsi
75
74
  env["rack.hijack"] = method(:hijack)
76
75
  headers.each do |(k, v)|
77
76
  env[case k
78
- when "content-type" then "CONTENT_TYPE"
79
- when "content-length" then "CONTENT_LENGTH"
80
- when "accept" then "HTTP_ACCEPT"
81
- when "accept-encoding" then "HTTP_ACCEPT_ENCODING"
82
- when "accept-language" then "HTTP_ACCEPT_LANGUAGE"
83
- when "user-agent" then "HTTP_USER_AGENT"
84
- when "referer" then "HTTP_REFERER"
85
- when "origin" then "HTTP_ORIGIN"
86
- when "cookie" then "HTTP_COOKIE"
87
- when "authorization" then "HTTP_AUTHORIZATION"
88
- when "x-forwarded-for" then "HTTP_X_FORWARDED_FOR"
89
- when "x-forwarded-proto" then "HTTP_X_FORWARDED_PROTO"
90
- else RACK_HEADER_MAP[k]
91
- end
77
+ when "content-type" then "CONTENT_TYPE"
78
+ when "content-length" then "CONTENT_LENGTH"
79
+ when "accept" then "HTTP_ACCEPT"
80
+ when "accept-encoding" then "HTTP_ACCEPT_ENCODING"
81
+ when "accept-language" then "HTTP_ACCEPT_LANGUAGE"
82
+ when "user-agent" then "HTTP_USER_AGENT"
83
+ when "referer" then "HTTP_REFERER"
84
+ when "origin" then "HTTP_ORIGIN"
85
+ when "cookie" then "HTTP_COOKIE"
86
+ when "authorization" then "HTTP_AUTHORIZATION"
87
+ when "x-forwarded-for" then "HTTP_X_FORWARDED_FOR"
88
+ when "x-forwarded-proto" then "HTTP_X_FORWARDED_PROTO"
89
+ else RACK_HEADER_MAP[k]
90
+ end
92
91
  ] = v
93
92
  end
94
93
  env
@@ -154,8 +153,8 @@ module Itsi
154
153
  def build_input_io
155
154
  case body_parts
156
155
  when nil then EMPTY_IO
157
- when String then StringIO.new(body_parts)
158
- when Array then File.open(body_parts.first, "rb")
156
+ when String then StringIO.new(body_parts).tap { |io| io.set_encoding(Encoding::ASCII_8BIT) }
157
+ when Array then File.open(body_parts.first, "rb").tap { |io| io.set_encoding(Encoding::ASCII_8BIT) }
159
158
  else body_parts
160
159
  end
161
160
  end
@@ -5,9 +5,10 @@ prev: deny_list/
5
5
  next: controller/
6
6
  ---
7
7
 
8
+ > If you're after running a rack app using a fully-featured framework, e.g. a Ruby on Rails or Sinatra, take a look at the [Rackup File](/middleware/rackup_file) middleware instead.
9
+
8
10
  The **endpoint** middleware allows you to define an ultra light-weight, inline, Ruby endpoint.
9
11
 
10
- > If you're after running a rack app using a fully-featured framework, e.g. a Ruby on Rails or Sinatra, take a look at the [Rackup File](/middleware/rackup_file) middleware instead.
11
12
  This feature can be useful for quickly prototyping, building small pieces of isolated functionality, or minimal endpoints where high throughput is essential.
12
13
 
13
14
  `endpoint` has several variants, that further restrict the endpoint to respond to specific HTTP methods:
@@ -9,11 +9,11 @@ Itsi can automatically generate TLS certificates for you, both in development an
9
9
  To automatically generate a TLS certificate in development, just bind using the `https` scheme.
10
10
  E.g.
11
11
  ```ruby {filename=Itsi.rb}
12
- bind "https://localhost"
12
+ bind "https://0.0.0.0"
13
13
 
14
14
  or
15
15
 
16
- bind "https://localhost:8443"
16
+ bind "https://0.0.0.0:8443"
17
17
  ```
18
18
  Itsi will generate a local development CA for you if it does not yet exist, then use this to
19
19
  sign a just-in-time certificate for your server.
@@ -3,7 +3,7 @@ title: Scheduler Threads
3
3
  url: /options/scheduler_threads
4
4
  ---
5
5
 
6
- You can explicitly spawn a pool of non-blocking scheduler threads and divide work across traditional blocking and non-blocking threads, using [location](/middleware/location) blocks.
6
+ You can explicitly spawn a pool of non-blocking scheduler threads and divide work across traditional/blocking and non-blocking threads, using [location](/middleware/location) blocks.
7
7
 
8
8
  This allows you to safely dip your toes into using non-blocking threads for specific I/O heavy operations without having to port an entire application to non-blocking I/O.
9
9
 
@@ -31,8 +31,8 @@ fiber_scheduler nil
31
31
 
32
32
  # If you bind to https, without specifying a certificate, Itsi will use a self-signed certificate.
33
33
  # The self-signed certificate will use a CA generated for your host and stored inside `ITSI_LOCAL_CA_DIR` (Defaults to ~/.itsi)
34
- # bind "https://localhost:3000"
35
- # bind "https://localhost:3000?domains=dev.itsi.fyi"
34
+ # bind "https://0.0.0.0:3000"
35
+ # bind "https://0.0.0.0:3000?domains=dev.itsi.fyi"
36
36
  #
37
37
  # If you want to use let's encrypt to generate you a real certificate you and pass cert=acme and an acme_email address to generate one.
38
38
  # bind "https://itsi.fyi?cert=acme&acme_email=admin@itsi.fyi"
@@ -8,10 +8,11 @@ module Rack
8
8
  port = options.fetch(:Port, 3001)
9
9
  ::Itsi::Server.start(
10
10
  {
11
- app: app,
12
11
  binds: ["http://#{host}:#{port}"]
13
12
  }
14
- )
13
+ ) do
14
+ run app
15
+ end
15
16
  end
16
17
  end
17
18
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Itsi
4
4
  class Server
5
- VERSION = "0.2.10"
5
+ VERSION = "0.2.11"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: itsi-server
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.10
4
+ version: 0.2.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wouter Coppieters
@@ -91,7 +91,6 @@ files:
91
91
  - ".rubocop.yml"
92
92
  - Cargo.lock
93
93
  - Cargo.toml
94
- - README.md
95
94
  - Rakefile
96
95
  - exe/itsi
97
96
  - ext/itsi_acme/Cargo.toml
data/README.md DELETED
@@ -1,49 +0,0 @@
1
- ---
2
- type: docs
3
- sidebar:
4
- exclude: true
5
- ---
6
-
7
- # ItsiServer
8
-
9
- TODO: Delete this and the text below, and describe your gem
10
-
11
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/itsi_server`. To experiment with that code, run `bin/console` for an interactive prompt.
12
-
13
- ## Installation
14
-
15
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
16
-
17
- Install the gem and add to the application's Gemfile by executing:
18
-
19
- ```bash
20
- bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
21
- ```
22
-
23
- If bundler is not being used to manage dependencies, install the gem by executing:
24
-
25
- ```bash
26
- gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
27
- ```
28
-
29
- ## Usage
30
-
31
- TODO: Write usage instructions here
32
-
33
- ## Development
34
-
35
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
36
-
37
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
38
-
39
- ## Contributing
40
-
41
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/itsi_server. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/itsi_server/blob/master/CODE_OF_CONDUCT.md).
42
-
43
- ## License
44
-
45
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
46
-
47
- ## Code of Conduct
48
-
49
- Everyone interacting in the ItsiServer project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/itsi_server/blob/master/CODE_OF_CONDUCT.md).