Skip to content

Instantly share code, notes, and snippets.

@rummelonp
Created September 27, 2013 09:26
Show Gist options
  • Save rummelonp/6726153 to your computer and use it in GitHub Desktop.
Save rummelonp/6726153 to your computer and use it in GitHub Desktop.
source 'https://rubygems.org'
gem 'sinatra'
gem 'puma'
gem 'thin'
# -*- coding: utf-8 -*-
require 'sinatra'
require 'puma'
set :server, :puma
get '/' do
string = 'にゃーん'
stream do |out|
loop do
out << string += '!'
out << "\r\n"
sleep 1
end
end
end
# -*- coding: utf-8 -*-
require 'sinatra'
require 'thin'
set :server, :thin
get '/' do
string = 'にゃーん'
stream do |out|
loop do
out << string += '!'
out << "\r\n"
sleep 1
end
end
end
@rummelonp
Copy link
Author

$ ruby puma.rb > /dev/null 2>&1 &
$ curl -v http://localhost:4567/
* About to connect() to localhost port 4567 (#0)
*   Trying ::1...
* connected
* Connected to localhost (::1) port 4567 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 OpenSSL/0.9.8y zlib/1.2.5
> Host: localhost:4567
> Accept: */*
> 
< HTTP/1.1 200 OK
< Content-Type: text/html;charset=utf-8
< X-XSS-Protection: 1; mode=block
< X-Content-Type-Options: nosniff
< X-Frame-Options: SAMEORIGIN
< Transfer-Encoding: chunked
< 
にゃーん!
にゃーん!!
$ ruby thin.rb > /dev/null 2>&1 &
$ curl -v http://localhost:4567/
* About to connect() to localhost port 4567 (#0)
*   Trying ::1...
* Connection refused
*   Trying 127.0.0.1...
* connected
* Connected to localhost (127.0.0.1) port 4567 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 OpenSSL/0.9.8y zlib/1.2.5
> Host: localhost:4567
> Accept: */*
> 
< HTTP/1.1 200 OK
< Content-Type: text/html;charset=utf-8
< X-XSS-Protection: 1; mode=block
< X-Content-Type-Options: nosniff
< X-Frame-Options: SAMEORIGIN
< Connection: close
< Server: thin 1.5.1 codename Straight Razor
< 
にゃーん!
にゃーん!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment