rack

How do I log asynchronous thin+sinatra+rack requests?

天大地大妈咪最大 提交于 2019-12-04 10:20:11
I'm writing my first Sinatra-based web app as a frontend to another TCP-based service, using EventMachine and async_sinatra to process incoming HTTP requests asynchronously. When I'm testing my app, all requests to synchronous routes are logged to stdout in common log format, but asynchronous requests are not. I've read through bits of the source code to async_sinatra, Sinatra, Thin, and Rack, and it looks like logging of synchronous requests is done through CommonLogger#call. However, I can't find anywhere in the asynchronous code in async_sinatra or Thin that seems to pass asynchronous

Rack Error with DreamHost, Passenger, and Rails 3.0.0.rc

梦想的初衷 提交于 2019-12-04 09:49:58
Background: I have viewed this question as well as this one - sadly, to no avail. Error Message (Passenger): You have already activated rack 1.1.0, but your Gemfile requires rack 1.2.1. Consider using bundle exec. my Gemfile: source 'http://rubygems.org' gem 'rails', '3.0.0.rc' gem 'nifty-generators' gem 'nokogiri' group :after_initialize do gem 'feedzirra' end my Gemfile.lock has this line: rack (1.2.1) my environment.rb has this line at the top: ENV['GEM_PATH'] = File.expand_path('~/.gems') + ':/usr/lib/ruby/gems/1.8' my boot.rb has this line at the top: Gem.clear_paths I have rack (1.2.1)

You have already activated rack 1.6.0, but your Gemfile requires rack 1.6.4

早过忘川 提交于 2019-12-04 09:08:18
问题 Similar to problem with rack 1.3.2. You have already activated rack 1.3.2, but your Gemfile requires rack 1.2.3 -- I'm experiencing You have already activated rack 1.6.0, but your Gemfile requires rack 1.6.4 when attempting to run Rails (4.2) in production with Puma and Nginx. bundle update rake nor rm Gemfile.lock && bundle install seem to help, the only solution I have so far is manually changing rack (1.6.4) to rack (1.6.0) in Gemfile.lock. 回答1: you need to uninstall one version of rack

Sinatra, JavaScript Cross-Domain Requests JSON

限于喜欢 提交于 2019-12-04 08:46:31
问题 I run a REST-API build on top of Sinatra. Now I want to write a jQuery Script that fetches data from the API. Sinatra is told to response with JSON before do content_type :json end A simple Route looks like get '/posts' do Post.find.to_json end My jQuery script is a simple ajax-call $.ajax({ type: 'get', url: 'http://api.com/posts', dataType: 'json', success: function(data) { // do something } }) Actually everything works fine as long as both runs on the same IP, API and requesting JS. I

Rack Sessions getting lost in Chrome

╄→гoц情女王★ 提交于 2019-12-04 07:26:09
I have an pretty simple app hosted on EC2 built with Sinatra, served with thin behind nginx. The problem is that with Chrome, the session variables get 'lost' in Sinatra. It does not happen in Firefox. This is using Rack::Session::Cookie. This is similar to this issue: Sinatra not persisting session with redirect on Chrome Any insights in how to solve this issues in Chrome would be appreciated. Make sure you are setting the following: configure :development do set(:session_secret, 'a random string that wont change') end configure :production do set(:session_secret, '*&(${)UIJH$(&*(&*(@(*)(!))

What is the difference between a Cookie and Redis Session store?

喜欢而已 提交于 2019-12-04 05:54:08
I want to share sessions among 2 applications on different nodes; however, I am confused what the difference is between Cookie and Redis session stores; e.g. a cookie session might look like this: rack.session=BAh7BkkiD3Nlc3Npb25faWQGOgZFRiJFN2YxZDMxMGE5YTNhZjc2NGM1NDBk%0AMzdiODQ0MjcyMzk5MzAxY2YyYzdhNDMwOWVkMzhiNWVlMmY2N2QwYzExNg%3D%3D%0A--ec4ec7b5a807c806e02e2811f4a11d05877a7698 In Redis, a session-store, might look like this: rack:session:eb23c0a055e9e6de3b8ad51efd9g6260d647b2e61326e35f5ff59cd490bfb405" However, I am confused how these sessions can be shared. Whereas in a cookie approach, a

Rack rack.input variable getting truncated?

允我心安 提交于 2019-12-04 04:43:22
I wrote a piece of Rack Middleware to automatically unzip compressed request bodies. The code seems to be working just fine, but when I plug it into my rails app, I get a failure "Invalid JSON" from ActionController::ParamsParser. As a debugging mechanism, I'm writing both the zipped content, and the unzipped content to a file (to make sure that code is working properly) and I do receive my original JSON document (before the client zips it up). The data I'm posting is JSON data, and the unzipped content is detected as valid JSON from http://jsonlint.com . Any ideas what I'm doing wrong? class

Rack Session Cookie and Sinatra - setting and accessing data

谁说我不能喝 提交于 2019-12-04 03:43:14
I was using Rack Session Pool, however my users would get kicked off one webserver thread onto another making the session data expire. I started toying around with just enable :sessions in Sinatra, however I am unable to use that because I have mutliple apps using Sinatra (same key it appears to be using - not sure if this is because its the same host or not) So since my apps would break each other, I now am trying Rack Session Cookie and setting the variables (same thing as enable :sessions, but you can set the variables) Great so that works! But now I cannot access the session data the way I

What's the difference between rack app vs. rails app?

余生颓废 提交于 2019-12-04 01:48:37
I uploaded my rails 2.3.8 app to DreamHost and got an error about rack version incompatibility. I issued a support ticket and the service guy recommended that I delete config.ru. That solved the problem. But I wonder what that would affect. Is it ok that a rails app goes without config.ru? A Rack app is a web app written in Ruby that uses the Rack project. A really simple Hello World config.ru example is like so: class HelloWorld def call(env) [200, {'Content-Type' => 'text/plain'}, ['Hello World!']] end end run HelloWorld.new Rails 2.3+ uses Rack as the basis for its HTTP handling, but some

Can I have Sinatra / Rack not read the entire request body into memory?

非 Y 不嫁゛ 提交于 2019-12-03 17:25:16
Say I have a Sinatra route ala: put '/data' do request.body.read # ... end It appears that the entire request.body is read into memory. Is there a way to consume the body as it comes into the system, rather than having it all buffered in Rack/Sinatra beforehand? I see I can do this to read the body in parts, but the entire body still seems to be read into memory beforehand. put '/data' do while request.body.read(1024) != nil # ... end # ... end Konstantin Haase You cannot avoid this in general without patching Sinatra and/or Rack. It is done by Rack::Request when request.POST is called by