Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

updates for 1.3.5

  • Loading branch information...
commit b283c7f33e156cd389bca7e1c65a05de4e72e894 1 parent b57ce87
@rkh rkh authored
View
39 _includes/README.html
@@ -1121,18 +1121,33 @@
point in the execution flow. This only works on evented servers, like Thin
and Rainbows. Other servers will still close the stream:</p>
-<pre>set :server, :thin
+<pre># long polling
+
+set :server, :thin
connections = []
-get '/' do
- # keep stream open
+get '/subscribe' do
+ # register a client's interest in server events
stream(:keep_open) { |out| connections &lt;&lt; out }
+
+ # purge dead connections
+ connections.reject!(&amp;:closed?)
+
+ # acknowledge
+ &quot;subscribed&quot;
end
-post '/' do
- # write to all open streams
- connections.each { |out| out &lt;&lt; params[:message] &lt;&lt; &quot;\n&quot; }
- &quot;message sent&quot;
+post '/message' do
+ connections.each do |out|
+ # notify client that a new message has arrived
+ out &lt;&lt; params[:message] &lt;&lt; &quot;\n&quot;
+
+ # indicate client to connect again
+ out.close
+ end
+
+ # acknowledge
+ &quot;message received&quot;
end</pre>
<a name='Logging'></a>
@@ -1381,7 +1396,7 @@
request.host # &quot;example.com&quot;
request.get? # true (similar methods for other verbs)
request.form_data? # false
- request[&quot;SOME_HEADER&quot;] # value of SOME_HEADER header
+ request[&quot;some_param&quot;] # value of some_param parameter. [] is a shortcut to the params hash.
request.referrer # the referrer of the client or '/'
request.user_agent # user agent (used by :agent condition)
request.cookies # hash of browser cookies
@@ -1558,8 +1573,8 @@
<p>Sinatra is using <a
href="https://github.com/rkh/rack-protection#readme">Rack::Protection</a>
to defend your application against common, opportunistic attacks. You can
-easily disable this behavior (which will open your application to tons of
-common vulnerabilities):</p>
+easily disable this behavior (which will open up your application to tons
+of common vulnerabilities):</p>
<pre>disable :protection</pre>
@@ -1947,7 +1962,7 @@
<p>Or with a <tt>config.ru</tt>, which allows using any Rack handler:</p>
-<pre># config.ru
+<pre># config.ru (run with rackup)
require './my_app'
run MyApp</pre>
@@ -2038,7 +2053,7 @@
<p>It takes the application to inherit from as optional argument:</p>
-<pre># config.ru
+<pre># config.ru (run with rackup)
require 'sinatra/base'
controller = Sinatra.new do
View
2  _includes/README.ru.html
@@ -1458,7 +1458,7 @@
request.host # &quot;example.com&quot;
request.get? # true (есть аналоги для других методов HTTP)
request.form_data? # false
- request[&quot;SOME_HEADER&quot;] # значение заголовка SOME_HEADER
+ request[&quot;some_param&quot;] # значение параметра some_param. Шорткат для хеша params
request.referrer # источник запроса клиента либо '/'
request.user_agent # user agent (используется для :agent условия)
request.cookies # хеш, содержащий cookies браузера
View
2  documentation.markdown
@@ -52,6 +52,8 @@ in `#sinatra`.
See the `CHANGES` file included for release notes about each release:
+ * [1.3.5](https://github.com/sinatra/sinatra/blob/1.3.5/CHANGES)
+ February 25, 2013
* [1.3.4](https://github.com/sinatra/sinatra/blob/1.3.4/CHANGES)
January 26, 2013
* [1.3.3](https://github.com/sinatra/sinatra/blob/1.3.3/CHANGES)

0 comments on commit b283c7f

Please sign in to comment.
Something went wrong with that request. Please try again.