Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sinatra completely incompatible with HTTP gem. #881

Closed
krainboltgreene opened this issue Jun 6, 2014 · 10 comments
Closed

Sinatra completely incompatible with HTTP gem. #881

krainboltgreene opened this issue Jun 6, 2014 · 10 comments

Comments

@krainboltgreene
Copy link

The http.gem defines a top level HTTP constant, a module.

Sinatra looks for a top level HTTP constant and calls run on it, regardless of if you want it to do that.

This is pretty weird and I'm going to say, since top level constants (in my opinion) should be reserved for namespaces that the http.gem wins.

Why is Sinatra doing this possibly dangerous thing on a global constant? What if there's an HTTP constant with a .run method that does something the user doesn't want to do?

@krainboltgreene
Copy link
Author

Bringing in @tarcieri since it's his gem.

@tarcieri
Copy link

tarcieri commented Jun 6, 2014

Got a link to the relevant Sinatra code?

@krainboltgreene
Copy link
Author

Here's an example of the error:

/Users/krainboltgreene/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1497:in `start_server': undefined method `run' for HTTP:Module (NoMethodError)
    from /Users/krainboltgreene/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1435:in `run!'
    from /Users/krainboltgreene/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/main.rb:25:in `block in <module:Sinatra>'

@tarcieri
Copy link

tarcieri commented Jun 6, 2014

@krainboltgreene
Copy link
Author

The primary prefernece issue is here: https://github.com/sinatra/sinatra/blob/master/lib/sinatra/base.rb#L1862

@krainboltgreene
Copy link
Author

@tarcieri Yep, based on the preference. The preference by default defines two "servers": "HTTP" and "webrick". It then goes over each of those server "names" and feeds them to Rack::Handler (helpfully swallowing up errors): https://github.com/sinatra/sinatra/blob/master/lib/sinatra/base.rb#L1766

@tarcieri
Copy link

tarcieri commented Jun 6, 2014

What else is HTTP supposed to be besides my gem, especially when it comes to an HTTP server?

@rkh
Copy link
Member

rkh commented Jun 6, 2014

I think this is a bug in Rack. It should check for Rack::Handler::HTTP, provided by net-http-server.

The relevant code is in rack/handler.

@krainboltgreene
Copy link
Author

Alright, I'll bring it up with them and submit a PR. Thanks!

On Fri, Jun 6, 2014 at 4:07 PM, Konstantin Haase notifications@github.com
wrote:

I think this is a bug in Rack. It should check for Rack::Handler::HTTP,
provided by net-http-server
https://github.com/postmodern/net-http-server/blob/master/lib/rack/handler/http.rb
.

The relevant code is in rack/handler
https://github.com/rack/rack/blob/master/lib/rack/handler.rb.


Reply to this email directly or view it on GitHub
#881 (comment).

Kurtis Rainbolt-Greene, Hacker
Software Developer
1631 8th St.
New Orleans, LA
70115

bradleyscott added a commit to ryankscott/ruby_chat_service that referenced this issue Nov 9, 2014
@zzak
Copy link
Member

zzak commented Feb 11, 2015

Not sure this is something we can fix in Sinatra, giving it a close.

Please feel free to discuss this issue on Rack.

@zzak zzak closed this as completed Feb 11, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants