1
0
Fork 0
mirror of https://github.com/puma/puma.git synced 2022-11-09 13:48:40 -05:00
Commit graph

26 commits

Author SHA1 Message Date
Nate Berkopec
d91c112fee
Merge branch 'removes-connected-port' of https://github.com/drews256/puma into drews256-removes-connected-port 2020-02-27 10:27:00 -06:00
James Christie
5b8f557714
remove setting quiet requests inside puma rack handler (#2075)
* remove setting quiet requests inside puma rack handler

* added test cases for user and file config of log_requests

* update test cases to use example files

Co-authored-by: Nate Berkopec <nate.berkopec@gmail.com>
2020-02-19 10:53:09 -06:00
Andrew Stuntz
c4f6ac08ee Removes connected_port, implements connected_ports
This work starts the effort of removing connected_port from the specs.

I have moved the code around a bit to get all connected_ports, the tests seem
to pass in the appropriate areas.

I want to verify this path before attempting to remove all UniquePort calls in
the tests.
2019-11-19 10:51:18 -08:00
Nate Berkopec
5f84f37944
Remove unnecessary calls to abort_on_exception 2019-09-11 12:36:40 +00:00
schneems
c24c0c8834 Rack handler should use provided default host
This issue is somewhat tricky. When Rails is booted via `rails server` there are two types of configuration options passed, ones specified directly by a user like `rails s -p 3001` will always "win".

For any other config that is not explicitly passed in, puma will consider it a "default". For example when you run `rails s` (without -p) then the default port will be 3000.

There is one other way to configure puma though, and that is via a config file:

```
# config/puma.rb
port 3002
```

This is the order of precedence for configuration

1) Anything the user explicitly passes to `rails s`
2) Config specified in `config/puma.rb` file
3) Default values passed in via `rails s`
4) Defaults values stored in puma

This fallback mechanism works well except in the case of calling `port` in a `config/puma.rb` file. To understand look at the [old method definition](2668597ec1/lib/puma/dsl.rb (L140-L145)):

```
def port(port, host=nil)
  host ||= Configuration::DefaultTCPHost
  bind "tcp://#{host}:#{port}"
end
```

When the `port` method gets called, even if the user did not specify a `host` the `Configuration::DefaultTCPHost` will be used, which is a problem for local development because it defaults to `0.0.0.0`. [SO about 0.0.0.0 versus localhost](https://stackoverflow.com/questions/20778771/what-is-the-difference-between-0-0-0-0-127-0-0-1-and-localhost).

In this case, while a user did directly specify a port, they did not specify a host, so you would expect the `rails s` defaults passed in to take affect.

To make Puma respect that the host coming from `rails s` has more precedence than it's own default host, we must introduce the ability to set and retrieve a default_host value.

This is then used in the rack handler so when `rails s` passes in `:Host => "localhost"` then it is used instead of reverting to `0.0.0.0`.

The issue with #1699 is the test was wrong, it would have failed if a config file was present with a `port` invocation.
2019-01-04 16:09:56 -06:00
MSP-Greg
4bb40e117f windows add two tests - test\test_rack_handler.rb 2018-09-21 17:14:16 -05:00
MSP-Greg
6a7112d51b Update test files
1. Update skip handling
2. Stability changes
3. Add Ruby & OpenSSL version info output
4. Bypassed SSL tests on DISABLE_SSL ?
2018-09-11 16:31:54 -05:00
Vladimir Dementyev
42580133a8 Use Rubocop 0.50; fix SpaceBeforeBlockBraces layout (#1472) 2017-11-30 08:52:40 -07:00
schneems
0584a3345e [close #1327] Fix double port bind in Rails
The "default" configuration puma level is initialized with a "binds" of `tcp://0.0.0.0:9292`. Puma is designed to be able to bind to multiple ports. 

When a `:port` is sent from Rails along with an empty `user_supplied_options` then the port is treated as a "default". This is merged in with the system defaults, and then later converted into a "binds" via calling `config.port` in the `set_host_port_to_config` method. 

The bug comes due to the "level" of the configuration. Since both are being set on the same "level" the `port` call does not over-write the existing binds but instead prepends to the array. We can fix by ensuring that any binds in a given "level" are empty before setting it.
2017-08-02 14:28:39 -05:00
Nikolay Vashchenko
a31a62656d Appveyor CI (#1374)
* appveyour config

* proper platforms for windows

* disabling tests with ssl and interrupts

* excessive ssl setup

* fixed message

* adding info in readme regarding stopgap_13632

* formatting

* trailing spaces
2017-07-27 12:18:58 -06:00
Vladimir Dementyev
2cb2357d39 Let's use Rubocop! (#1325)
* Add limited rubocop config and TODO config

* Remove trailing whitespaces and blanklines

* Add rubocop rake task; upd travis.yml
2017-06-04 13:21:05 -07:00
Michael Grosser
9d93a0f62f make test_helper no longer be loaded as a test (#1283)
running `rake` loads all files starting with `test_` which is not supposed to also load the helper,
since the helper should be loaded by each test and is not a test itself.
2017-05-12 12:16:55 -07:00
Richard Schneeman
328687d8de [Close #1255] Prefer user supplied defaults (#1277)
To build a "binds" we need a host IP (via Host) and a port. We were running into a problem where a Host was being explicitly set via user but the Port was being defaulted to by Rails. When this happened the Host was used, but Puma would accidentally use it's own default port 9292 instead of Rail's port of 3000.

The fix was to use the "default" port passed in from a framework (if available) when no explicitly set Port is provided.
2017-05-01 09:54:53 -07:00
Michael Grosser
d25ef26465 warn when bundler fails and avoid having to use -I to run tests (#1270) 2017-04-11 14:48:11 -07:00
schneems
852f52fcf7 Clean up tests 2017-03-09 11:38:27 -06:00
schneems
85dfe8edcf Implement user_supplied_options behavior.
When options are passed to the Puma rack handler it is unknown if the options were set via a framework as a default or via a user. Puma currently has 3 different sources of configuration, the user via command line, the config files, and defaults. 

Rails 5.1+ will record the values actually specified by the user versus the values specified by the frameworks. It passes these values to the Rack handler and now it's up to Puma to do something with that information.

When only framework defaults are passed it will set

```
options[:user_supplied_options] = []
```

When one or more options are specified by the user such as `:Port` then those keys will be in the array. In that example it will look like this


```
options[:user_supplied_options] = [:Port]
```

This change is 100% backwards compatible. If the framework is older and does not pass this information then the `user_supplied_options` will not be set, in that case we assume all values are user supplied.

Internally we accomplish this separation by replacing `LeveledOptions` which was a generic way of specifying options with different priorities with a more explicit `UserFileDefaultOptions` this assumes only 3 levels of options and it will use them in the order supplied (user config wins over file based config wins over defaults).

Now instead of using 1 dsl to set all values, we use 3. A user dsl, a file dsl and a Configuration.new` will return all 3 DSLs to the block. It's up to the person using the block to use the correct dsl corresponding to the source of data they are getting.
2017-03-09 11:38:26 -06:00
schneems
24f12579bf Use config file before default port with handler 2017-03-09 11:38:26 -06:00
schneems
cda9317e71 Split out config into explicit user and file parts 2017-03-09 11:38:26 -06:00
schneems
c946d15dc2 Failing test of desired behavior 2017-03-09 11:38:26 -06:00
Francesco Rodriguez
b638dd1948 Use Minitest instead of Test::Unit (#1152)
* Bump minitest version.

* Add basic test helper file.

* Use minitest for web server tests.

* Use Minitest for unix socket tests.

* Use Minitest for ThreadPool tests.

* Use Minitest for TCP-Rack tests

* Use Minitest for TCPLogger tests.

* Add missing helper to test helpers.

* Use Minitest for Rack server tests.

* Use Minitest for Rack handler tests.

* Use Minitest for Puma::Server tests.

* Use Minitest for Puma::Server with SSL tests.

* Use Minitest for persisten connections tests.

* Require puma in test_helper file.

* Use minitest for Puma::NullIO tests.

* Remove unnecessary requires on test files.

* Use Minitest for MiniSSL tests.

* Use Minitest for IOBuffer tests.

* Require bundler/setup in Rakefile.

* Use Minitest for HttpParser tests.

* Use Minitest for Puma::Configuration tests.

* Use Minitest for Puma::CLI tests.

* Bump Minitest version for Ruby 2.1 Gemfile.

* Use Minitest for integration tests.

* Use Minitest for Puma::App::Status tests.

* Remove test-unit from Gemfiles.

* Add timeout helper to Minitest::Test.

* Use Minitest for Puma::Binder tests.

* Remove testhelp file.

* Add missing require to Puma::Binder tests.

* Prefer require instead of require_relative.
2016-11-22 08:05:49 -07:00
Jun Aruga
cc23d01c9b Improve required testhelp.rb path. 2016-09-21 10:39:40 +02:00
Evan Phoenix
f788af0c8f Continue API cleanup, preparing for 3.0 2016-02-06 19:00:29 -08:00
schneems
023c0c8ecd Fix rack handler test to use port 0 2016-02-04 16:55:10 -06:00
schneems
d6df5cec22 Switch puma rack handler to use Launcher 2016-02-04 16:55:10 -06:00
schneems
6c4ff1aa9c Add test for rack handler 2016-02-04 16:55:10 -06:00
Konstantin Haase
7c41cf7bb7 add Rack handler for Puma 2011-10-04 14:23:51 -07:00