oneflow-recover-output.html

Error returned by oneflow - Nicolas Belan, 03/06/2014 02:39 PM

Download (196 KB)

 
1
<!DOCTYPE html>
2
<html>
3
<head>
4
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
5
  <title>NameError at &#x2F;service&#x2F;17&#x2F;action</title>
6

    
7
  <script type="text/javascript">
8
  //<!--
9
  function toggle(id) {
10
    var pre  = document.getElementById("pre-" + id);
11
    var post = document.getElementById("post-" + id);
12
    var context = document.getElementById("context-" + id);
13

14
    if (pre.style.display == 'block') {
15
      pre.style.display = 'none';
16
      post.style.display = 'none';
17
      context.style.background = "none";
18
    } else {
19
      pre.style.display = 'block';
20
      post.style.display = 'block';
21
      context.style.background = "#fffed9";
22
    }
23
  }
24

25
  function toggleBacktrace(){
26
    var bt = document.getElementById("backtrace");
27
    var toggler = document.getElementById("expando");
28

29
    if (bt.className == 'condensed') {
30
      bt.className = 'expanded';
31
      toggler.innerHTML = "(condense)";
32
    } else {
33
      bt.className = 'condensed';
34
      toggler.innerHTML = "(expand)";
35
    }
36
  }
37
  //-->
38
  </script>
39

    
40
<style type="text/css" media="screen">
41
  *                   {margin: 0; padding: 0; border: 0; outline: 0;}
42
  div.clear           {clear: both;}
43
  body                {background: #EEEEEE; margin: 0; padding: 0;
44
                       font-family: 'Lucida Grande', 'Lucida Sans Unicode',
45
                       'Garuda';}
46
  code                {font-family: 'Lucida Console', monospace;
47
                       font-size: 12px;}
48
  li                  {height: 18px;}
49
  ul                  {list-style: none; margin: 0; padding: 0;}
50
  ol:hover            {cursor: pointer;}
51
  ol li               {white-space: pre;}
52
  #explanation        {font-size: 12px; color: #666666;
53
                       margin: 20px 0 0 100px;}
54
/* WRAP */
55
  #wrap               {width: 1000px; background: #FFFFFF; margin: 0 auto;
56
                       padding: 30px 50px 20px 50px;
57
                       border-left: 1px solid #DDDDDD;
58
                       border-right: 1px solid #DDDDDD;}
59
/* HEADER */
60
  #header             {margin: 0 auto 25px auto;}
61
  #header img         {float: left;}
62
  #header #summary    {float: left; margin: 12px 0 0 20px; width:660px;
63
                       font-family: 'Lucida Grande', 'Lucida Sans Unicode';}
64
  h1                  {margin: 0; font-size: 36px; color: #981919;}
65
  h2                  {margin: 0; font-size: 22px; color: #333333;}
66
  #header ul          {margin: 0; font-size: 12px; color: #666666;}
67
  #header ul li strong{color: #444444;}
68
  #header ul li       {display: inline; padding: 0 10px;}
69
  #header ul li.first {padding-left: 0;}
70
  #header ul li.last  {border: 0; padding-right: 0;}
71
/* BODY */
72
  #backtrace,
73
  #get,
74
  #post,
75
  #cookies,
76
  #rack               {width: 980px; margin: 0 auto 10px auto;}
77
  p#nav               {float: right; font-size: 14px;}
78
/* BACKTRACE */
79
  a#expando           {float: left; padding-left: 5px; color: #666666;
80
                      font-size: 14px; text-decoration: none; cursor: pointer;}
81
  a#expando:hover     {text-decoration: underline;}
82
  h3                  {float: left; width: 100px; margin-bottom: 10px;
83
                       color: #981919; font-size: 14px; font-weight: bold;}
84
  #nav a              {color: #666666; text-decoration: none; padding: 0 5px;}
85
  #backtrace li.frame-info {background: #f7f7f7; padding-left: 10px;
86
                           font-size: 12px; color: #333333;}
87
  #backtrace ul       {list-style-position: outside; border: 1px solid #E9E9E9;
88
                       border-bottom: 0;}
89
  #backtrace ol       {width: 920px; margin-left: 50px;
90
                       font: 10px 'Lucida Console', monospace; color: #666666;}
91
  #backtrace ol li    {border: 0; border-left: 1px solid #E9E9E9;
92
                       padding: 2px 0;}
93
  #backtrace ol code  {font-size: 10px; color: #555555; padding-left: 5px;}
94
  #backtrace-ul li    {border-bottom: 1px solid #E9E9E9; height: auto;
95
                       padding: 3px 0;}
96
  #backtrace-ul .code {padding: 6px 0 4px 0;}
97
  #backtrace.condensed .system,
98
  #backtrace.condensed .framework {display:none;}
99
/* REQUEST DATA */
100
  p.no-data           {padding-top: 2px; font-size: 12px; color: #666666;}
101
  table.req           {width: 980px; text-align: left; font-size: 12px;
102
                       color: #666666; padding: 0; border-spacing: 0;
103
                       border: 1px solid #EEEEEE; border-bottom: 0;
104
                       border-left: 0;
105
                       clear:both}
106
  table.req tr th     {padding: 2px 10px; font-weight: bold;
107
                       background: #F7F7F7; border-bottom: 1px solid #EEEEEE;
108
                       border-left: 1px solid #EEEEEE;}
109
  table.req tr td     {padding: 2px 20px 2px 10px;
110
                       border-bottom: 1px solid #EEEEEE;
111
                       border-left: 1px solid #EEEEEE;}
112
/* HIDE PRE/POST CODE AT START */
113
  .pre-context,
114
  .post-context       {display: none;}
115

116
  table td.code       {width:750px}
117
  table td.code div   {width:750px;overflow:hidden}
118
</style>
119
</head>
120
<body>
121
  <div id="wrap">
122
    <div id="header">
123
      <img src="/__sinatra__/500.png" alt="application error" height="161" width="313" />
124
      <div id="summary">
125
        <h1><strong>NameError</strong> at <strong>&#x2F;service&#x2F;17&#x2F;action
126
          </strong></h1>
127
        <h2>undefined local variable or method `n_dispose&#x27; for #&lt;OpenNebula::Role:0x7f4fad11d588&gt;</h2>
128
        <ul>
129
          <li class="first"><strong>file:</strong> <code>
130
            role.rb</code></li>
131
          <li><strong>location:</strong> <code>retry_scale
132
            </code></li>
133
          <li class="last"><strong>line:
134
            </strong> 798</li>
135
        </ul>
136
      </div>
137
      <div class="clear"></div>
138
    </div>
139

    
140
    <div id="backtrace" class='condensed'>
141
      <h3>BACKTRACE</h3>
142
      <p><a href="#" id="expando"
143
            onclick="toggleBacktrace(); return false">(expand)</a></p>
144
      <p id="nav"><strong>JUMP TO:</strong>
145
         <a href="#get-info">GET</a>
146
         <a href="#post-info">POST</a>
147
         <a href="#cookie-info">COOKIES</a>
148
         <a href="#env-info">ENV</a>
149
      </p>
150
      <div class="clear"></div>
151

    
152
      <ul id="backtrace-ul">
153

    
154
      
155
      
156
          
157

    
158
            <li class="frame-info app">
159
              <code>&#x2F;usr&#x2F;lib&#x2F;one&#x2F;oneflow&#x2F;lib&#x2F;models&#x2F;role.rb</code> in
160
                <code><strong>retry_scale</strong></code>
161
            </li>
162

    
163
            <li class="code app">
164
              
165
              <ol start="791"
166
                  class="pre-context" id="pre-1"
167
                  onclick="toggle(1);">
168
                
169
                <li class="pre-context-line"><code>        def retry_scale()
170
</code></li>
171
                
172
                <li class="pre-context-line"><code>            nodes_dispose = get_nodes.select { |node|
173
</code></li>
174
                
175
                <li class="pre-context-line"><code>                node[&#x27;disposed&#x27;] == &quot;1&quot;
176
</code></li>
177
                
178
                <li class="pre-context-line"><code>            }
179
</code></li>
180
                
181
                <li class="pre-context-line"><code>
182
</code></li>
183
                
184
                <li class="pre-context-line"><code>            shutdown_nodes(nodes_dispose, true)
185
</code></li>
186
                
187
                <li class="pre-context-line"><code>
188
</code></li>
189
                
190
              </ol>
191
              
192

    
193
              <ol start="798" class="context" id="1"
194
                  onclick="toggle(1);">
195
                <li class="context-line" id="context-1"><code>            set_cardinality( get_nodes.size() - n_dispose.size() )</code></li>
196
              </ol>
197

    
198
              
199
              <ol start="799" class="post-context"
200
                  id="post-1" onclick="toggle(1);">
201
                
202
                <li class="post-context-line"><code>        end
203
</code></li>
204
                
205
                <li class="post-context-line"><code>
206
</code></li>
207
                
208
                <li class="post-context-line"><code>        # Deletes VMs in DONE or FAILED, and sends a boot action to VMs in UNKNOWN
209
</code></li>
210
                
211
                <li class="post-context-line"><code>        def recover()
212
</code></li>
213
                
214
                <li class="post-context-line"><code>
215
</code></li>
216
                
217
                <li class="post-context-line"><code>            nodes = @body[&#x27;nodes&#x27;]
218
</code></li>
219
                
220
                <li class="post-context-line"><code>            new_nodes = []
221
</code></li>
222
                
223
              </ol>
224
              
225
              <div class="clear"></div>
226
            </li>
227

    
228
          
229

    
230
        
231
      
232
          
233

    
234
            <li class="frame-info app">
235
              <code>&#x2F;usr&#x2F;lib&#x2F;one&#x2F;oneflow&#x2F;lib&#x2F;models&#x2F;role.rb</code> in
236
                <code><strong>recover_scale</strong></code>
237
            </li>
238

    
239
            <li class="code app">
240
              
241
              <ol start="586"
242
                  class="pre-context" id="pre-2"
243
                  onclick="toggle(2);">
244
                
245
                <li class="pre-context-line"><code>        def recover_warning()
246
</code></li>
247
                
248
                <li class="pre-context-line"><code>            recover()
249
</code></li>
250
                
251
                <li class="pre-context-line"><code>            deploy()
252
</code></li>
253
                
254
                <li class="pre-context-line"><code>        end
255
</code></li>
256
                
257
                <li class="pre-context-line"><code>
258
</code></li>
259
                
260
                <li class="pre-context-line"><code>        def recover_scale()
261
</code></li>
262
                
263
                <li class="pre-context-line"><code>            recover()
264
</code></li>
265
                
266
              </ol>
267
              
268

    
269
              <ol start="593" class="context" id="2"
270
                  onclick="toggle(2);">
271
                <li class="context-line" id="context-2"><code>            retry_scale()</code></li>
272
              </ol>
273

    
274
              
275
              <ol start="594" class="post-context"
276
                  id="post-2" onclick="toggle(2);">
277
                
278
                <li class="post-context-line"><code>        end
279
</code></li>
280
                
281
                <li class="post-context-line"><code>
282
</code></li>
283
                
284
                <li class="post-context-line"><code>
285
</code></li>
286
                
287
                <li class="post-context-line"><code>        ########################################################################
288
</code></li>
289
                
290
                <li class="post-context-line"><code>        ########################################################################
291
</code></li>
292
                
293
                <li class="post-context-line"><code>
294
</code></li>
295
                
296
                <li class="post-context-line"><code>
297
</code></li>
298
                
299
              </ol>
300
              
301
              <div class="clear"></div>
302
            </li>
303

    
304
          
305

    
306
        
307
      
308
          
309

    
310
            <li class="frame-info app">
311
              <code>&#x2F;usr&#x2F;lib&#x2F;one&#x2F;oneflow&#x2F;lib&#x2F;models&#x2F;service.rb</code> in
312
                <code><strong>recover</strong></code>
313
            </li>
314

    
315
            <li class="code app">
316
              
317
              <ol start="211"
318
                  class="pre-context" id="pre-3"
319
                  onclick="toggle(3);">
320
                
321
                <li class="pre-context-line"><code>                end
322
</code></li>
323
                
324
                <li class="pre-context-line"><code>
325
</code></li>
326
                
327
                <li class="pre-context-line"><code>                self.set_state(Service::STATE[&#x27;DEPLOYING&#x27;])
328
</code></li>
329
                
330
                <li class="pre-context-line"><code>
331
</code></li>
332
                
333
                <li class="pre-context-line"><code>            elsif self.state == Service::STATE[&#x27;FAILED_SCALING&#x27;]
334
</code></li>
335
                
336
                <li class="pre-context-line"><code>                @roles.each do |name, role|
337
</code></li>
338
                
339
                <li class="pre-context-line"><code>                    if role.state == Role::STATE[&#x27;FAILED_SCALING&#x27;]
340
</code></li>
341
                
342
              </ol>
343
              
344

    
345
              <ol start="218" class="context" id="3"
346
                  onclick="toggle(3);">
347
                <li class="context-line" id="context-3"><code>                        role.recover_scale()</code></li>
348
              </ol>
349

    
350
              
351
              <ol start="219" class="post-context"
352
                  id="post-3" onclick="toggle(3);">
353
                
354
                <li class="post-context-line"><code>                        role.set_state(Role::STATE[&#x27;SCALING&#x27;])
355
</code></li>
356
                
357
                <li class="post-context-line"><code>                    end
358
</code></li>
359
                
360
                <li class="post-context-line"><code>                end
361
</code></li>
362
                
363
                <li class="post-context-line"><code>
364
</code></li>
365
                
366
                <li class="post-context-line"><code>                self.set_state(Service::STATE[&#x27;SCALING&#x27;])
367
</code></li>
368
                
369
                <li class="post-context-line"><code>
370
</code></li>
371
                
372
                <li class="post-context-line"><code>            elsif self.state == Service::STATE[&#x27;FAILED_UNDEPLOYING&#x27;]
373
</code></li>
374
                
375
              </ol>
376
              
377
              <div class="clear"></div>
378
            </li>
379

    
380
          
381

    
382
        
383
      
384
          
385

    
386
            <li class="frame-info app">
387
              <code>&#x2F;usr&#x2F;lib&#x2F;one&#x2F;oneflow&#x2F;lib&#x2F;models&#x2F;service.rb</code> in
388
                <code><strong>each</strong></code>
389
            </li>
390

    
391
            <li class="code app">
392
              
393
              <ol start="209"
394
                  class="pre-context" id="pre-4"
395
                  onclick="toggle(4);">
396
                
397
                <li class="pre-context-line"><code>                        role.recover_deployment()
398
</code></li>
399
                
400
                <li class="pre-context-line"><code>                    end
401
</code></li>
402
                
403
                <li class="pre-context-line"><code>                end
404
</code></li>
405
                
406
                <li class="pre-context-line"><code>
407
</code></li>
408
                
409
                <li class="pre-context-line"><code>                self.set_state(Service::STATE[&#x27;DEPLOYING&#x27;])
410
</code></li>
411
                
412
                <li class="pre-context-line"><code>
413
</code></li>
414
                
415
                <li class="pre-context-line"><code>            elsif self.state == Service::STATE[&#x27;FAILED_SCALING&#x27;]
416
</code></li>
417
                
418
              </ol>
419
              
420

    
421
              <ol start="216" class="context" id="4"
422
                  onclick="toggle(4);">
423
                <li class="context-line" id="context-4"><code>                @roles.each do |name, role|</code></li>
424
              </ol>
425

    
426
              
427
              <ol start="217" class="post-context"
428
                  id="post-4" onclick="toggle(4);">
429
                
430
                <li class="post-context-line"><code>                    if role.state == Role::STATE[&#x27;FAILED_SCALING&#x27;]
431
</code></li>
432
                
433
                <li class="post-context-line"><code>                        role.recover_scale()
434
</code></li>
435
                
436
                <li class="post-context-line"><code>                        role.set_state(Role::STATE[&#x27;SCALING&#x27;])
437
</code></li>
438
                
439
                <li class="post-context-line"><code>                    end
440
</code></li>
441
                
442
                <li class="post-context-line"><code>                end
443
</code></li>
444
                
445
                <li class="post-context-line"><code>
446
</code></li>
447
                
448
                <li class="post-context-line"><code>                self.set_state(Service::STATE[&#x27;SCALING&#x27;])
449
</code></li>
450
                
451
              </ol>
452
              
453
              <div class="clear"></div>
454
            </li>
455

    
456
          
457

    
458
        
459
      
460
          
461

    
462
            <li class="frame-info app">
463
              <code>&#x2F;usr&#x2F;lib&#x2F;one&#x2F;oneflow&#x2F;lib&#x2F;models&#x2F;service.rb</code> in
464
                <code><strong>recover</strong></code>
465
            </li>
466

    
467
            <li class="code app">
468
              
469
              <ol start="209"
470
                  class="pre-context" id="pre-5"
471
                  onclick="toggle(5);">
472
                
473
                <li class="pre-context-line"><code>                        role.recover_deployment()
474
</code></li>
475
                
476
                <li class="pre-context-line"><code>                    end
477
</code></li>
478
                
479
                <li class="pre-context-line"><code>                end
480
</code></li>
481
                
482
                <li class="pre-context-line"><code>
483
</code></li>
484
                
485
                <li class="pre-context-line"><code>                self.set_state(Service::STATE[&#x27;DEPLOYING&#x27;])
486
</code></li>
487
                
488
                <li class="pre-context-line"><code>
489
</code></li>
490
                
491
                <li class="pre-context-line"><code>            elsif self.state == Service::STATE[&#x27;FAILED_SCALING&#x27;]
492
</code></li>
493
                
494
              </ol>
495
              
496

    
497
              <ol start="216" class="context" id="5"
498
                  onclick="toggle(5);">
499
                <li class="context-line" id="context-5"><code>                @roles.each do |name, role|</code></li>
500
              </ol>
501

    
502
              
503
              <ol start="217" class="post-context"
504
                  id="post-5" onclick="toggle(5);">
505
                
506
                <li class="post-context-line"><code>                    if role.state == Role::STATE[&#x27;FAILED_SCALING&#x27;]
507
</code></li>
508
                
509
                <li class="post-context-line"><code>                        role.recover_scale()
510
</code></li>
511
                
512
                <li class="post-context-line"><code>                        role.set_state(Role::STATE[&#x27;SCALING&#x27;])
513
</code></li>
514
                
515
                <li class="post-context-line"><code>                    end
516
</code></li>
517
                
518
                <li class="post-context-line"><code>                end
519
</code></li>
520
                
521
                <li class="post-context-line"><code>
522
</code></li>
523
                
524
                <li class="post-context-line"><code>                self.set_state(Service::STATE[&#x27;SCALING&#x27;])
525
</code></li>
526
                
527
              </ol>
528
              
529
              <div class="clear"></div>
530
            </li>
531

    
532
          
533

    
534
        
535
      
536
          
537

    
538
            <li class="frame-info app">
539
              <code>&#x2F;usr&#x2F;lib&#x2F;one&#x2F;oneflow&#x2F;oneflow-server.rb</code> in
540
                <code><strong>POST &#x2F;service&#x2F;:id&#x2F;action</strong></code>
541
            </li>
542

    
543
            <li class="code app">
544
              
545
              <ol start="192"
546
                  class="pre-context" id="pre-6"
547
                  onclick="toggle(6);">
548
                
549
                <li class="pre-context-line"><code>
550
</code></li>
551
                
552
                <li class="pre-context-line"><code>    rc = nil
553
</code></li>
554
                
555
                <li class="pre-context-line"><code>    service = service_pool.get(params[:id]) { |service|
556
</code></li>
557
                
558
                <li class="pre-context-line"><code>        rc = case action[&#x27;perform&#x27;]
559
</code></li>
560
                
561
                <li class="pre-context-line"><code>        when &#x27;shutdown&#x27;
562
</code></li>
563
                
564
                <li class="pre-context-line"><code>            service.shutdown
565
</code></li>
566
                
567
                <li class="pre-context-line"><code>        when &#x27;recover&#x27;, &#x27;deploy&#x27;
568
</code></li>
569
                
570
              </ol>
571
              
572

    
573
              <ol start="199" class="context" id="6"
574
                  onclick="toggle(6);">
575
                <li class="context-line" id="context-6"><code>            service.recover</code></li>
576
              </ol>
577

    
578
              
579
              <ol start="200" class="post-context"
580
                  id="post-6" onclick="toggle(6);">
581
                
582
                <li class="post-context-line"><code>        when &#x27;chown&#x27;
583
</code></li>
584
                
585
                <li class="post-context-line"><code>            if opts &amp;&amp; opts[&#x27;owner_id&#x27;]
586
</code></li>
587
                
588
                <li class="post-context-line"><code>                args = Array.new
589
</code></li>
590
                
591
                <li class="post-context-line"><code>                args &lt;&lt; opts[&#x27;owner_id&#x27;].to_i
592
</code></li>
593
                
594
                <li class="post-context-line"><code>                args &lt;&lt; (opts[&#x27;group_id&#x27;] || -1).to_i
595
</code></li>
596
                
597
                <li class="post-context-line"><code>
598
</code></li>
599
                
600
                <li class="post-context-line"><code>                ret = service.chown(*args)
601
</code></li>
602
                
603
              </ol>
604
              
605
              <div class="clear"></div>
606
            </li>
607

    
608
          
609

    
610
        
611
      
612
          
613

    
614
            <li class="frame-info app">
615
              <code>&#x2F;usr&#x2F;lib&#x2F;one&#x2F;oneflow&#x2F;lib&#x2F;models&#x2F;service_pool.rb</code> in
616
                <code><strong>call</strong></code>
617
            </li>
618

    
619
            <li class="code app">
620
              
621
              <ol start="77"
622
                  class="pre-context" id="pre-7"
623
                  onclick="toggle(7);">
624
                
625
                <li class="pre-context-line"><code>                            @@mutex_hash.delete_if { |s_id, entry|
626
</code></li>
627
                
628
                <li class="pre-context-line"><code>                                entry[1] == 0
629
</code></li>
630
                
631
                <li class="pre-context-line"><code>                            }
632
</code></li>
633
                
634
                <li class="pre-context-line"><code>                        end
635
</code></li>
636
                
637
                <li class="pre-context-line"><code>                    }
638
</code></li>
639
                
640
                <li class="pre-context-line"><code>
641
</code></li>
642
                
643
                <li class="pre-context-line"><code>                    obj_mutex.synchronize {
644
</code></li>
645
                
646
              </ol>
647
              
648

    
649
              <ol start="84" class="context" id="7"
650
                  onclick="toggle(7);">
651
                <li class="context-line" id="context-7"><code>                        block.call(service)</code></li>
652
              </ol>
653

    
654
              
655
              <ol start="85" class="post-context"
656
                  id="post-7" onclick="toggle(7);">
657
                
658
                <li class="post-context-line"><code>                    }
659
</code></li>
660
                
661
                <li class="post-context-line"><code>
662
</code></li>
663
                
664
                <li class="post-context-line"><code>                    @@mutex.synchronize {
665
</code></li>
666
                
667
                <li class="post-context-line"><code>                        entry[1] = entry[1] - 1
668
</code></li>
669
                
670
                <li class="post-context-line"><code>                    }
671
</code></li>
672
                
673
                <li class="post-context-line"><code>                end
674
</code></li>
675
                
676
                <li class="post-context-line"><code>
677
</code></li>
678
                
679
              </ol>
680
              
681
              <div class="clear"></div>
682
            </li>
683

    
684
          
685

    
686
        
687
      
688
          
689

    
690
            <li class="frame-info app">
691
              <code>&#x2F;usr&#x2F;lib&#x2F;one&#x2F;oneflow&#x2F;lib&#x2F;models&#x2F;service_pool.rb</code> in
692
                <code><strong>get</strong></code>
693
            </li>
694

    
695
            <li class="code app">
696
              
697
              <ol start="77"
698
                  class="pre-context" id="pre-8"
699
                  onclick="toggle(8);">
700
                
701
                <li class="pre-context-line"><code>                            @@mutex_hash.delete_if { |s_id, entry|
702
</code></li>
703
                
704
                <li class="pre-context-line"><code>                                entry[1] == 0
705
</code></li>
706
                
707
                <li class="pre-context-line"><code>                            }
708
</code></li>
709
                
710
                <li class="pre-context-line"><code>                        end
711
</code></li>
712
                
713
                <li class="pre-context-line"><code>                    }
714
</code></li>
715
                
716
                <li class="pre-context-line"><code>
717
</code></li>
718
                
719
                <li class="pre-context-line"><code>                    obj_mutex.synchronize {
720
</code></li>
721
                
722
              </ol>
723
              
724

    
725
              <ol start="84" class="context" id="8"
726
                  onclick="toggle(8);">
727
                <li class="context-line" id="context-8"><code>                        block.call(service)</code></li>
728
              </ol>
729

    
730
              
731
              <ol start="85" class="post-context"
732
                  id="post-8" onclick="toggle(8);">
733
                
734
                <li class="post-context-line"><code>                    }
735
</code></li>
736
                
737
                <li class="post-context-line"><code>
738
</code></li>
739
                
740
                <li class="post-context-line"><code>                    @@mutex.synchronize {
741
</code></li>
742
                
743
                <li class="post-context-line"><code>                        entry[1] = entry[1] - 1
744
</code></li>
745
                
746
                <li class="post-context-line"><code>                    }
747
</code></li>
748
                
749
                <li class="post-context-line"><code>                end
750
</code></li>
751
                
752
                <li class="post-context-line"><code>
753
</code></li>
754
                
755
              </ol>
756
              
757
              <div class="clear"></div>
758
            </li>
759

    
760
          
761

    
762
        
763
      
764
          
765

    
766
            <li class="frame-info app">
767
              <code>&#x2F;usr&#x2F;lib&#x2F;one&#x2F;oneflow&#x2F;lib&#x2F;models&#x2F;service_pool.rb</code> in
768
                <code><strong>synchronize</strong></code>
769
            </li>
770

    
771
            <li class="code app">
772
              
773
              <ol start="76"
774
                  class="pre-context" id="pre-9"
775
                  onclick="toggle(9);">
776
                
777
                <li class="pre-context-line"><code>                        if @@mutex_hash.size &gt; 10000
778
</code></li>
779
                
780
                <li class="pre-context-line"><code>                            @@mutex_hash.delete_if { |s_id, entry|
781
</code></li>
782
                
783
                <li class="pre-context-line"><code>                                entry[1] == 0
784
</code></li>
785
                
786
                <li class="pre-context-line"><code>                            }
787
</code></li>
788
                
789
                <li class="pre-context-line"><code>                        end
790
</code></li>
791
                
792
                <li class="pre-context-line"><code>                    }
793
</code></li>
794
                
795
                <li class="pre-context-line"><code>
796
</code></li>
797
                
798
              </ol>
799
              
800

    
801
              <ol start="83" class="context" id="9"
802
                  onclick="toggle(9);">
803
                <li class="context-line" id="context-9"><code>                    obj_mutex.synchronize {</code></li>
804
              </ol>
805

    
806
              
807
              <ol start="84" class="post-context"
808
                  id="post-9" onclick="toggle(9);">
809
                
810
                <li class="post-context-line"><code>                        block.call(service)
811
</code></li>
812
                
813
                <li class="post-context-line"><code>                    }
814
</code></li>
815
                
816
                <li class="post-context-line"><code>
817
</code></li>
818
                
819
                <li class="post-context-line"><code>                    @@mutex.synchronize {
820
</code></li>
821
                
822
                <li class="post-context-line"><code>                        entry[1] = entry[1] - 1
823
</code></li>
824
                
825
                <li class="post-context-line"><code>                    }
826
</code></li>
827
                
828
                <li class="post-context-line"><code>                end
829
</code></li>
830
                
831
              </ol>
832
              
833
              <div class="clear"></div>
834
            </li>
835

    
836
          
837

    
838
        
839
      
840
          
841

    
842
            <li class="frame-info app">
843
              <code>&#x2F;usr&#x2F;lib&#x2F;one&#x2F;oneflow&#x2F;lib&#x2F;models&#x2F;service_pool.rb</code> in
844
                <code><strong>get</strong></code>
845
            </li>
846

    
847
            <li class="code app">
848
              
849
              <ol start="76"
850
                  class="pre-context" id="pre-10"
851
                  onclick="toggle(10);">
852
                
853
                <li class="pre-context-line"><code>                        if @@mutex_hash.size &gt; 10000
854
</code></li>
855
                
856
                <li class="pre-context-line"><code>                            @@mutex_hash.delete_if { |s_id, entry|
857
</code></li>
858
                
859
                <li class="pre-context-line"><code>                                entry[1] == 0
860
</code></li>
861
                
862
                <li class="pre-context-line"><code>                            }
863
</code></li>
864
                
865
                <li class="pre-context-line"><code>                        end
866
</code></li>
867
                
868
                <li class="pre-context-line"><code>                    }
869
</code></li>
870
                
871
                <li class="pre-context-line"><code>
872
</code></li>
873
                
874
              </ol>
875
              
876

    
877
              <ol start="83" class="context" id="10"
878
                  onclick="toggle(10);">
879
                <li class="context-line" id="context-10"><code>                    obj_mutex.synchronize {</code></li>
880
              </ol>
881

    
882
              
883
              <ol start="84" class="post-context"
884
                  id="post-10" onclick="toggle(10);">
885
                
886
                <li class="post-context-line"><code>                        block.call(service)
887
</code></li>
888
                
889
                <li class="post-context-line"><code>                    }
890
</code></li>
891
                
892
                <li class="post-context-line"><code>
893
</code></li>
894
                
895
                <li class="post-context-line"><code>                    @@mutex.synchronize {
896
</code></li>
897
                
898
                <li class="post-context-line"><code>                        entry[1] = entry[1] - 1
899
</code></li>
900
                
901
                <li class="post-context-line"><code>                    }
902
</code></li>
903
                
904
                <li class="post-context-line"><code>                end
905
</code></li>
906
                
907
              </ol>
908
              
909
              <div class="clear"></div>
910
            </li>
911

    
912
          
913

    
914
        
915
      
916
          
917

    
918
            <li class="frame-info app">
919
              <code>&#x2F;usr&#x2F;lib&#x2F;one&#x2F;oneflow&#x2F;oneflow-server.rb</code> in
920
                <code><strong>POST &#x2F;service&#x2F;:id&#x2F;action</strong></code>
921
            </li>
922

    
923
            <li class="code app">
924
              
925
              <ol start="187"
926
                  class="pre-context" id="pre-11"
927
                  onclick="toggle(11);">
928
                
929
                <li class="pre-context-line"><code>
930
</code></li>
931
                
932
                <li class="pre-context-line"><code>post &#x27;&#x2F;service&#x2F;:id&#x2F;action&#x27; do
933
</code></li>
934
                
935
                <li class="pre-context-line"><code>    service_pool = OpenNebula::ServicePool.new(@client)
936
</code></li>
937
                
938
                <li class="pre-context-line"><code>    action = JSON.parse(request.body.read)[&#x27;action&#x27;]
939
</code></li>
940
                
941
                <li class="pre-context-line"><code>    opts   = action[&#x27;params&#x27;]
942
</code></li>
943
                
944
                <li class="pre-context-line"><code>
945
</code></li>
946
                
947
                <li class="pre-context-line"><code>    rc = nil
948
</code></li>
949
                
950
              </ol>
951
              
952

    
953
              <ol start="194" class="context" id="11"
954
                  onclick="toggle(11);">
955
                <li class="context-line" id="context-11"><code>    service = service_pool.get(params[:id]) { |service|</code></li>
956
              </ol>
957

    
958
              
959
              <ol start="195" class="post-context"
960
                  id="post-11" onclick="toggle(11);">
961
                
962
                <li class="post-context-line"><code>        rc = case action[&#x27;perform&#x27;]
963
</code></li>
964
                
965
                <li class="post-context-line"><code>        when &#x27;shutdown&#x27;
966
</code></li>
967
                
968
                <li class="post-context-line"><code>            service.shutdown
969
</code></li>
970
                
971
                <li class="post-context-line"><code>        when &#x27;recover&#x27;, &#x27;deploy&#x27;
972
</code></li>
973
                
974
                <li class="post-context-line"><code>            service.recover
975
</code></li>
976
                
977
                <li class="post-context-line"><code>        when &#x27;chown&#x27;
978
</code></li>
979
                
980
                <li class="post-context-line"><code>            if opts &amp;&amp; opts[&#x27;owner_id&#x27;]
981
</code></li>
982
                
983
              </ol>
984
              
985
              <div class="clear"></div>
986
            </li>
987

    
988
          
989

    
990
        
991
      
992
          
993

    
994
            <li class="frame-info framework">
995
              <code>&#x2F;usr&#x2F;lib&#x2F;ruby&#x2F;gems&#x2F;1.8&#x2F;gems&#x2F;sinatra-1.4.3&#x2F;lib&#x2F;sinatra&#x2F;base.rb</code> in
996
                <code><strong>call</strong></code>
997
            </li>
998

    
999
            <li class="code framework">
1000
              
1001
              <ol start="1533"
1002
                  class="pre-context" id="pre-12"
1003
                  onclick="toggle(12);">
1004
                
1005
                <li class="pre-context-line"><code>        options.each_pair { |option, args| send(option, *args) }
1006
</code></li>
1007
                
1008
                <li class="pre-context-line"><code>        method_name             = &quot;#{verb} #{path}&quot;
1009
</code></li>
1010
                
1011
                <li class="pre-context-line"><code>        unbound_method          = generate_method(method_name, &amp;block)
1012
</code></li>
1013
                
1014
                <li class="pre-context-line"><code>        pattern, keys           = compile path
1015
</code></li>
1016
                
1017
                <li class="pre-context-line"><code>        conditions, @conditions = @conditions, []
1018
</code></li>
1019
                
1020
                <li class="pre-context-line"><code>
1021
</code></li>
1022
                
1023
                <li class="pre-context-line"><code>        wrapper                 = block.arity != 0 ?
1024
</code></li>
1025
                
1026
              </ol>
1027
              
1028

    
1029
              <ol start="1540" class="context" id="12"
1030
                  onclick="toggle(12);">
1031
                <li class="context-line" id="context-12"><code>          proc { |a,p| unbound_method.bind(a).call(*p) } :</code></li>
1032
              </ol>
1033

    
1034
              
1035
              <ol start="1541" class="post-context"
1036
                  id="post-12" onclick="toggle(12);">
1037
                
1038
                <li class="post-context-line"><code>          proc { |a,p| unbound_method.bind(a).call }
1039
</code></li>
1040
                
1041
                <li class="post-context-line"><code>        wrapper.instance_variable_set(:@route_name, method_name)
1042
</code></li>
1043
                
1044
                <li class="post-context-line"><code>
1045
</code></li>
1046
                
1047
                <li class="post-context-line"><code>        [ pattern, keys, conditions, wrapper ]
1048
</code></li>
1049
                
1050
                <li class="post-context-line"><code>      end
1051
</code></li>
1052
                
1053
                <li class="post-context-line"><code>
1054
</code></li>
1055
                
1056
                <li class="post-context-line"><code>      def compile(path)
1057
</code></li>
1058
                
1059
              </ol>
1060
              
1061
              <div class="clear"></div>
1062
            </li>
1063

    
1064
          
1065

    
1066
        
1067
      
1068
          
1069

    
1070
            <li class="frame-info framework">
1071
              <code>&#x2F;usr&#x2F;lib&#x2F;ruby&#x2F;gems&#x2F;1.8&#x2F;gems&#x2F;sinatra-1.4.3&#x2F;lib&#x2F;sinatra&#x2F;base.rb</code> in
1072
                <code><strong>compile!</strong></code>
1073
            </li>
1074

    
1075
            <li class="code framework">
1076
              
1077
              <ol start="1533"
1078
                  class="pre-context" id="pre-13"
1079
                  onclick="toggle(13);">
1080
                
1081
                <li class="pre-context-line"><code>        options.each_pair { |option, args| send(option, *args) }
1082
</code></li>
1083
                
1084
                <li class="pre-context-line"><code>        method_name             = &quot;#{verb} #{path}&quot;
1085
</code></li>
1086
                
1087
                <li class="pre-context-line"><code>        unbound_method          = generate_method(method_name, &amp;block)
1088
</code></li>
1089
                
1090
                <li class="pre-context-line"><code>        pattern, keys           = compile path
1091
</code></li>
1092
                
1093
                <li class="pre-context-line"><code>        conditions, @conditions = @conditions, []
1094
</code></li>
1095
                
1096
                <li class="pre-context-line"><code>
1097
</code></li>
1098
                
1099
                <li class="pre-context-line"><code>        wrapper                 = block.arity != 0 ?
1100
</code></li>
1101
                
1102
              </ol>
1103
              
1104

    
1105
              <ol start="1540" class="context" id="13"
1106
                  onclick="toggle(13);">
1107
                <li class="context-line" id="context-13"><code>          proc { |a,p| unbound_method.bind(a).call(*p) } :</code></li>
1108
              </ol>
1109

    
1110
              
1111
              <ol start="1541" class="post-context"
1112
                  id="post-13" onclick="toggle(13);">
1113
                
1114
                <li class="post-context-line"><code>          proc { |a,p| unbound_method.bind(a).call }
1115
</code></li>
1116
                
1117
                <li class="post-context-line"><code>        wrapper.instance_variable_set(:@route_name, method_name)
1118
</code></li>
1119
                
1120
                <li class="post-context-line"><code>
1121
</code></li>
1122
                
1123
                <li class="post-context-line"><code>        [ pattern, keys, conditions, wrapper ]
1124
</code></li>
1125
                
1126
                <li class="post-context-line"><code>      end
1127
</code></li>
1128
                
1129
                <li class="post-context-line"><code>
1130
</code></li>
1131
                
1132
                <li class="post-context-line"><code>      def compile(path)
1133
</code></li>
1134
                
1135
              </ol>
1136
              
1137
              <div class="clear"></div>
1138
            </li>
1139

    
1140
          
1141

    
1142
        
1143
      
1144
          
1145

    
1146
            <li class="frame-info framework">
1147
              <code>&#x2F;usr&#x2F;lib&#x2F;ruby&#x2F;gems&#x2F;1.8&#x2F;gems&#x2F;sinatra-1.4.3&#x2F;lib&#x2F;sinatra&#x2F;base.rb</code> in
1148
                <code><strong>[]</strong></code>
1149
            </li>
1150

    
1151
            <li class="code framework">
1152
              
1153
              <ol start="943"
1154
                  class="pre-context" id="pre-14"
1155
                  onclick="toggle(14);">
1156
                
1157
                <li class="pre-context-line"><code>
1158
</code></li>
1159
                
1160
                <li class="pre-context-line"><code>    # Run routes defined on the class and all superclasses.
1161
</code></li>
1162
                
1163
                <li class="pre-context-line"><code>    def route!(base = settings, pass_block = nil)
1164
</code></li>
1165
                
1166
                <li class="pre-context-line"><code>      if routes = base.routes[@request.request_method]
1167
</code></li>
1168
                
1169
                <li class="pre-context-line"><code>        routes.each do |pattern, keys, conditions, block|
1170
</code></li>
1171
                
1172
                <li class="pre-context-line"><code>          pass_block = process_route(pattern, keys, conditions) do |*args|
1173
</code></li>
1174
                
1175
                <li class="pre-context-line"><code>            env[&#x27;sinatra.route&#x27;] = block.instance_variable_get(:@route_name)
1176
</code></li>
1177
                
1178
              </ol>
1179
              
1180

    
1181
              <ol start="950" class="context" id="14"
1182
                  onclick="toggle(14);">
1183
                <li class="context-line" id="context-14"><code>            route_eval { block[*args] }</code></li>
1184
              </ol>
1185

    
1186
              
1187
              <ol start="951" class="post-context"
1188
                  id="post-14" onclick="toggle(14);">
1189
                
1190
                <li class="post-context-line"><code>          end
1191
</code></li>
1192
                
1193
                <li class="post-context-line"><code>        end
1194
</code></li>
1195
                
1196
                <li class="post-context-line"><code>      end
1197
</code></li>
1198
                
1199
                <li class="post-context-line"><code>
1200
</code></li>
1201
                
1202
                <li class="post-context-line"><code>      # Run routes defined in superclass.
1203
</code></li>
1204
                
1205
                <li class="post-context-line"><code>      if base.superclass.respond_to?(:routes)
1206
</code></li>
1207
                
1208
                <li class="post-context-line"><code>        return route!(base.superclass, pass_block)
1209
</code></li>
1210
                
1211
              </ol>
1212
              
1213
              <div class="clear"></div>
1214
            </li>
1215

    
1216
          
1217

    
1218
        
1219
      
1220
          
1221

    
1222
            <li class="frame-info framework">
1223
              <code>&#x2F;usr&#x2F;lib&#x2F;ruby&#x2F;gems&#x2F;1.8&#x2F;gems&#x2F;sinatra-1.4.3&#x2F;lib&#x2F;sinatra&#x2F;base.rb</code> in
1224
                <code><strong>route!</strong></code>
1225
            </li>
1226

    
1227
            <li class="code framework">
1228
              
1229
              <ol start="943"
1230
                  class="pre-context" id="pre-15"
1231
                  onclick="toggle(15);">
1232
                
1233
                <li class="pre-context-line"><code>
1234
</code></li>
1235
                
1236
                <li class="pre-context-line"><code>    # Run routes defined on the class and all superclasses.
1237
</code></li>
1238
                
1239
                <li class="pre-context-line"><code>    def route!(base = settings, pass_block = nil)
1240
</code></li>
1241
                
1242
                <li class="pre-context-line"><code>      if routes = base.routes[@request.request_method]
1243
</code></li>
1244
                
1245
                <li class="pre-context-line"><code>        routes.each do |pattern, keys, conditions, block|
1246
</code></li>
1247
                
1248
                <li class="pre-context-line"><code>          pass_block = process_route(pattern, keys, conditions) do |*args|
1249
</code></li>
1250
                
1251
                <li class="pre-context-line"><code>            env[&#x27;sinatra.route&#x27;] = block.instance_variable_get(:@route_name)
1252
</code></li>
1253
                
1254
              </ol>
1255
              
1256

    
1257
              <ol start="950" class="context" id="15"
1258
                  onclick="toggle(15);">
1259
                <li class="context-line" id="context-15"><code>            route_eval { block[*args] }</code></li>
1260
              </ol>
1261

    
1262
              
1263
              <ol start="951" class="post-context"
1264
                  id="post-15" onclick="toggle(15);">
1265
                
1266
                <li class="post-context-line"><code>          end
1267
</code></li>
1268
                
1269
                <li class="post-context-line"><code>        end
1270
</code></li>
1271
                
1272
                <li class="post-context-line"><code>      end
1273
</code></li>
1274
                
1275
                <li class="post-context-line"><code>
1276
</code></li>
1277
                
1278
                <li class="post-context-line"><code>      # Run routes defined in superclass.
1279
</code></li>
1280
                
1281
                <li class="post-context-line"><code>      if base.superclass.respond_to?(:routes)
1282
</code></li>
1283
                
1284
                <li class="post-context-line"><code>        return route!(base.superclass, pass_block)
1285
</code></li>
1286
                
1287
              </ol>
1288
              
1289
              <div class="clear"></div>
1290
            </li>
1291

    
1292
          
1293

    
1294
        
1295
      
1296
          
1297

    
1298
            <li class="frame-info framework">
1299
              <code>&#x2F;usr&#x2F;lib&#x2F;ruby&#x2F;gems&#x2F;1.8&#x2F;gems&#x2F;sinatra-1.4.3&#x2F;lib&#x2F;sinatra&#x2F;base.rb</code> in
1300
                <code><strong>route_eval</strong></code>
1301
            </li>
1302

    
1303
            <li class="code framework">
1304
              
1305
              <ol start="959"
1306
                  class="pre-context" id="pre-16"
1307
                  onclick="toggle(16);">
1308
                
1309
                <li class="pre-context-line"><code>
1310
</code></li>
1311
                
1312
                <li class="pre-context-line"><code>      route_eval(&amp;pass_block) if pass_block
1313
</code></li>
1314
                
1315
                <li class="pre-context-line"><code>      route_missing
1316
</code></li>
1317
                
1318
                <li class="pre-context-line"><code>    end
1319
</code></li>
1320
                
1321
                <li class="pre-context-line"><code>
1322
</code></li>
1323
                
1324
                <li class="pre-context-line"><code>    # Run a route block and throw :halt with the result.
1325
</code></li>
1326
                
1327
                <li class="pre-context-line"><code>    def route_eval
1328
</code></li>
1329
                
1330
              </ol>
1331
              
1332

    
1333
              <ol start="966" class="context" id="16"
1334
                  onclick="toggle(16);">
1335
                <li class="context-line" id="context-16"><code>      throw :halt, yield</code></li>
1336
              </ol>
1337

    
1338
              
1339
              <ol start="967" class="post-context"
1340
                  id="post-16" onclick="toggle(16);">
1341
                
1342
                <li class="post-context-line"><code>    end
1343
</code></li>
1344
                
1345
                <li class="post-context-line"><code>
1346
</code></li>
1347
                
1348
                <li class="post-context-line"><code>    # If the current request matches pattern and conditions, fill params
1349
</code></li>
1350
                
1351
                <li class="post-context-line"><code>    # with keys and call the given block.
1352
</code></li>
1353
                
1354
                <li class="post-context-line"><code>    # Revert params afterwards.
1355
</code></li>
1356
                
1357
                <li class="post-context-line"><code>    #
1358
</code></li>
1359
                
1360
                <li class="post-context-line"><code>    # Returns pass block.
1361
</code></li>
1362
                
1363
              </ol>
1364
              
1365
              <div class="clear"></div>
1366
            </li>
1367

    
1368
          
1369

    
1370
        
1371
      
1372
          
1373

    
1374
            <li class="frame-info framework">
1375
              <code>&#x2F;usr&#x2F;lib&#x2F;ruby&#x2F;gems&#x2F;1.8&#x2F;gems&#x2F;sinatra-1.4.3&#x2F;lib&#x2F;sinatra&#x2F;base.rb</code> in
1376
                <code><strong>route!</strong></code>
1377
            </li>
1378

    
1379
            <li class="code framework">
1380
              
1381
              <ol start="943"
1382
                  class="pre-context" id="pre-17"
1383
                  onclick="toggle(17);">
1384
                
1385
                <li class="pre-context-line"><code>
1386
</code></li>
1387
                
1388
                <li class="pre-context-line"><code>    # Run routes defined on the class and all superclasses.
1389
</code></li>
1390
                
1391
                <li class="pre-context-line"><code>    def route!(base = settings, pass_block = nil)
1392
</code></li>
1393
                
1394
                <li class="pre-context-line"><code>      if routes = base.routes[@request.request_method]
1395
</code></li>
1396
                
1397
                <li class="pre-context-line"><code>        routes.each do |pattern, keys, conditions, block|
1398
</code></li>
1399
                
1400
                <li class="pre-context-line"><code>          pass_block = process_route(pattern, keys, conditions) do |*args|
1401
</code></li>
1402
                
1403
                <li class="pre-context-line"><code>            env[&#x27;sinatra.route&#x27;] = block.instance_variable_get(:@route_name)
1404
</code></li>
1405
                
1406
              </ol>
1407
              
1408

    
1409
              <ol start="950" class="context" id="17"
1410
                  onclick="toggle(17);">
1411
                <li class="context-line" id="context-17"><code>            route_eval { block[*args] }</code></li>
1412
              </ol>
1413

    
1414
              
1415
              <ol start="951" class="post-context"
1416
                  id="post-17" onclick="toggle(17);">
1417
                
1418
                <li class="post-context-line"><code>          end
1419
</code></li>
1420
                
1421
                <li class="post-context-line"><code>        end
1422
</code></li>
1423
                
1424
                <li class="post-context-line"><code>      end
1425
</code></li>
1426
                
1427
                <li class="post-context-line"><code>
1428
</code></li>
1429
                
1430
                <li class="post-context-line"><code>      # Run routes defined in superclass.
1431
</code></li>
1432
                
1433
                <li class="post-context-line"><code>      if base.superclass.respond_to?(:routes)
1434
</code></li>
1435
                
1436
                <li class="post-context-line"><code>        return route!(base.superclass, pass_block)
1437
</code></li>
1438
                
1439
              </ol>
1440
              
1441
              <div class="clear"></div>
1442
            </li>
1443

    
1444
          
1445

    
1446
        
1447
      
1448
          
1449

    
1450
            <li class="frame-info framework">
1451
              <code>&#x2F;usr&#x2F;lib&#x2F;ruby&#x2F;gems&#x2F;1.8&#x2F;gems&#x2F;sinatra-1.4.3&#x2F;lib&#x2F;sinatra&#x2F;base.rb</code> in
1452
                <code><strong>process_route</strong></code>
1453
            </li>
1454

    
1455
            <li class="code framework">
1456
              
1457
              <ol start="980"
1458
                  class="pre-context" id="pre-18"
1459
                  onclick="toggle(18);">
1460
                
1461
                <li class="pre-context-line"><code>      if values.any?
1462
</code></li>
1463
                
1464
                <li class="pre-context-line"><code>        original, @params = params, params.merge(&#x27;splat&#x27; =&gt; [], &#x27;captures&#x27; =&gt; values)
1465
</code></li>
1466
                
1467
                <li class="pre-context-line"><code>        keys.zip(values) { |k,v| Array === @params[k] ? @params[k] &lt;&lt; v : @params[k] = v if v }
1468
</code></li>
1469
                
1470
                <li class="pre-context-line"><code>      end
1471
</code></li>
1472
                
1473
                <li class="pre-context-line"><code>
1474
</code></li>
1475
                
1476
                <li class="pre-context-line"><code>      catch(:pass) do
1477
</code></li>
1478
                
1479
                <li class="pre-context-line"><code>        conditions.each { |c| throw :pass if c.bind(self).call == false }
1480
</code></li>
1481
                
1482
              </ol>
1483
              
1484

    
1485
              <ol start="987" class="context" id="18"
1486
                  onclick="toggle(18);">
1487
                <li class="context-line" id="context-18"><code>        block ? block[self, values] : yield(self, values)</code></li>
1488
              </ol>
1489

    
1490
              
1491
              <ol start="988" class="post-context"
1492
                  id="post-18" onclick="toggle(18);">
1493
                
1494
                <li class="post-context-line"><code>      end
1495
</code></li>
1496
                
1497
                <li class="post-context-line"><code>    ensure
1498
</code></li>
1499
                
1500
                <li class="post-context-line"><code>      @params = original if original
1501
</code></li>
1502
                
1503
                <li class="post-context-line"><code>    end
1504
</code></li>
1505
                
1506
                <li class="post-context-line"><code>
1507
</code></li>
1508
                
1509
                <li class="post-context-line"><code>    # No matching route was found or all routes passed. The default
1510
</code></li>
1511
                
1512
                <li class="post-context-line"><code>    # implementation is to forward the request downstream when running
1513
</code></li>
1514
                
1515
              </ol>
1516
              
1517
              <div class="clear"></div>
1518
            </li>
1519

    
1520
          
1521

    
1522
        
1523
      
1524
          
1525

    
1526
            <li class="frame-info framework">
1527
              <code>&#x2F;usr&#x2F;lib&#x2F;ruby&#x2F;gems&#x2F;1.8&#x2F;gems&#x2F;sinatra-1.4.3&#x2F;lib&#x2F;sinatra&#x2F;base.rb</code> in
1528
                <code><strong>catch</strong></code>
1529
            </li>
1530

    
1531
            <li class="code framework">
1532
              
1533
              <ol start="978"
1534
                  class="pre-context" id="pre-19"
1535
                  onclick="toggle(19);">
1536
                
1537
                <li class="pre-context-line"><code>      values += match.captures.to_a.map { |v| force_encoding URI.unescape(v) if v }
1538
</code></li>
1539
                
1540
                <li class="pre-context-line"><code>
1541
</code></li>
1542
                
1543
                <li class="pre-context-line"><code>      if values.any?
1544
</code></li>
1545
                
1546
                <li class="pre-context-line"><code>        original, @params = params, params.merge(&#x27;splat&#x27; =&gt; [], &#x27;captures&#x27; =&gt; values)
1547
</code></li>
1548
                
1549
                <li class="pre-context-line"><code>        keys.zip(values) { |k,v| Array === @params[k] ? @params[k] &lt;&lt; v : @params[k] = v if v }
1550
</code></li>
1551
                
1552
                <li class="pre-context-line"><code>      end
1553
</code></li>
1554
                
1555
                <li class="pre-context-line"><code>
1556
</code></li>
1557
                
1558
              </ol>
1559
              
1560

    
1561
              <ol start="985" class="context" id="19"
1562
                  onclick="toggle(19);">
1563
                <li class="context-line" id="context-19"><code>      catch(:pass) do</code></li>
1564
              </ol>
1565

    
1566
              
1567
              <ol start="986" class="post-context"
1568
                  id="post-19" onclick="toggle(19);">
1569
                
1570
                <li class="post-context-line"><code>        conditions.each { |c| throw :pass if c.bind(self).call == false }
1571
</code></li>
1572
                
1573
                <li class="post-context-line"><code>        block ? block[self, values] : yield(self, values)
1574
</code></li>
1575
                
1576
                <li class="post-context-line"><code>      end
1577
</code></li>
1578
                
1579
                <li class="post-context-line"><code>    ensure
1580
</code></li>
1581
                
1582
                <li class="post-context-line"><code>      @params = original if original
1583
</code></li>
1584
                
1585
                <li class="post-context-line"><code>    end
1586
</code></li>
1587
                
1588
                <li class="post-context-line"><code>
1589
</code></li>
1590
                
1591
              </ol>
1592
              
1593
              <div class="clear"></div>
1594
            </li>
1595

    
1596
          
1597

    
1598
        
1599
      
1600
          
1601

    
1602
            <li class="frame-info framework">
1603
              <code>&#x2F;usr&#x2F;lib&#x2F;ruby&#x2F;gems&#x2F;1.8&#x2F;gems&#x2F;sinatra-1.4.3&#x2F;lib&#x2F;sinatra&#x2F;base.rb</code> in
1604
                <code><strong>process_route</strong></code>
1605
            </li>
1606

    
1607
            <li class="code framework">
1608
              
1609
              <ol start="978"
1610
                  class="pre-context" id="pre-20"
1611
                  onclick="toggle(20);">
1612
                
1613
                <li class="pre-context-line"><code>      values += match.captures.to_a.map { |v| force_encoding URI.unescape(v) if v }
1614
</code></li>
1615
                
1616
                <li class="pre-context-line"><code>
1617
</code></li>
1618
                
1619
                <li class="pre-context-line"><code>      if values.any?
1620
</code></li>
1621
                
1622
                <li class="pre-context-line"><code>        original, @params = params, params.merge(&#x27;splat&#x27; =&gt; [], &#x27;captures&#x27; =&gt; values)
1623
</code></li>
1624
                
1625
                <li class="pre-context-line"><code>        keys.zip(values) { |k,v| Array === @params[k] ? @params[k] &lt;&lt; v : @params[k] = v if v }
1626
</code></li>
1627
                
1628
                <li class="pre-context-line"><code>      end
1629
</code></li>
1630
                
1631
                <li class="pre-context-line"><code>
1632
</code></li>
1633
                
1634
              </ol>
1635
              
1636

    
1637
              <ol start="985" class="context" id="20"
1638
                  onclick="toggle(20);">
1639
                <li class="context-line" id="context-20"><code>      catch(:pass) do</code></li>
1640
              </ol>
1641

    
1642
              
1643
              <ol start="986" class="post-context"
1644
                  id="post-20" onclick="toggle(20);">
1645
                
1646
                <li class="post-context-line"><code>        conditions.each { |c| throw :pass if c.bind(self).call == false }
1647
</code></li>
1648
                
1649
                <li class="post-context-line"><code>        block ? block[self, values] : yield(self, values)
1650
</code></li>
1651
                
1652
                <li class="post-context-line"><code>      end
1653
</code></li>
1654
                
1655
                <li class="post-context-line"><code>    ensure
1656
</code></li>
1657
                
1658
                <li class="post-context-line"><code>      @params = original if original
1659
</code></li>
1660
                
1661
                <li class="post-context-line"><code>    end
1662
</code></li>
1663
                
1664
                <li class="post-context-line"><code>
1665
</code></li>
1666
                
1667
              </ol>
1668
              
1669
              <div class="clear"></div>
1670
            </li>
1671

    
1672
          
1673

    
1674
        
1675
      
1676
          
1677

    
1678
            <li class="frame-info framework">
1679
              <code>&#x2F;usr&#x2F;lib&#x2F;ruby&#x2F;gems&#x2F;1.8&#x2F;gems&#x2F;sinatra-1.4.3&#x2F;lib&#x2F;sinatra&#x2F;base.rb</code> in
1680
                <code><strong>route!</strong></code>
1681
            </li>
1682

    
1683
            <li class="code framework">
1684
              
1685
              <ol start="941"
1686
                  class="pre-context" id="pre-21"
1687
                  onclick="toggle(21);">
1688
                
1689
                <li class="pre-context-line"><code>      base.filters[type].each { |args| process_route(*args) }
1690
</code></li>
1691
                
1692
                <li class="pre-context-line"><code>    end
1693
</code></li>
1694
                
1695
                <li class="pre-context-line"><code>
1696
</code></li>
1697
                
1698
                <li class="pre-context-line"><code>    # Run routes defined on the class and all superclasses.
1699
</code></li>
1700
                
1701
                <li class="pre-context-line"><code>    def route!(base = settings, pass_block = nil)
1702
</code></li>
1703
                
1704
                <li class="pre-context-line"><code>      if routes = base.routes[@request.request_method]
1705
</code></li>
1706
                
1707
                <li class="pre-context-line"><code>        routes.each do |pattern, keys, conditions, block|
1708
</code></li>
1709
                
1710
              </ol>
1711
              
1712

    
1713
              <ol start="948" class="context" id="21"
1714
                  onclick="toggle(21);">
1715
                <li class="context-line" id="context-21"><code>          pass_block = process_route(pattern, keys, conditions) do |*args|</code></li>
1716
              </ol>
1717

    
1718
              
1719
              <ol start="949" class="post-context"
1720
                  id="post-21" onclick="toggle(21);">
1721
                
1722
                <li class="post-context-line"><code>            env[&#x27;sinatra.route&#x27;] = block.instance_variable_get(:@route_name)
1723
</code></li>
1724
                
1725
                <li class="post-context-line"><code>            route_eval { block[*args] }
1726
</code></li>
1727
                
1728
                <li class="post-context-line"><code>          end
1729
</code></li>
1730
                
1731
                <li class="post-context-line"><code>        end
1732
</code></li>
1733
                
1734
                <li class="post-context-line"><code>      end
1735
</code></li>
1736
                
1737
                <li class="post-context-line"><code>
1738
</code></li>
1739
                
1740
                <li class="post-context-line"><code>      # Run routes defined in superclass.
1741
</code></li>
1742
                
1743
              </ol>
1744
              
1745
              <div class="clear"></div>
1746
            </li>
1747

    
1748
          
1749

    
1750
        
1751
      
1752
          
1753

    
1754
            <li class="frame-info framework">
1755
              <code>&#x2F;usr&#x2F;lib&#x2F;ruby&#x2F;gems&#x2F;1.8&#x2F;gems&#x2F;sinatra-1.4.3&#x2F;lib&#x2F;sinatra&#x2F;base.rb</code> in
1756
                <code><strong>each</strong></code>
1757
            </li>
1758

    
1759
            <li class="code framework">
1760
              
1761
              <ol start="940"
1762
                  class="pre-context" id="pre-22"
1763
                  onclick="toggle(22);">
1764
                
1765
                <li class="pre-context-line"><code>      filter! type, base.superclass if base.superclass.respond_to?(:filters)
1766
</code></li>
1767
                
1768
                <li class="pre-context-line"><code>      base.filters[type].each { |args| process_route(*args) }
1769
</code></li>
1770
                
1771
                <li class="pre-context-line"><code>    end
1772
</code></li>
1773
                
1774
                <li class="pre-context-line"><code>
1775
</code></li>
1776
                
1777
                <li class="pre-context-line"><code>    # Run routes defined on the class and all superclasses.
1778
</code></li>
1779
                
1780
                <li class="pre-context-line"><code>    def route!(base = settings, pass_block = nil)
1781
</code></li>
1782
                
1783
                <li class="pre-context-line"><code>      if routes = base.routes[@request.request_method]
1784
</code></li>
1785
                
1786
              </ol>
1787
              
1788

    
1789
              <ol start="947" class="context" id="22"
1790
                  onclick="toggle(22);">
1791
                <li class="context-line" id="context-22"><code>        routes.each do |pattern, keys, conditions, block|</code></li>
1792
              </ol>
1793

    
1794
              
1795
              <ol start="948" class="post-context"
1796
                  id="post-22" onclick="toggle(22);">
1797
                
1798
                <li class="post-context-line"><code>          pass_block = process_route(pattern, keys, conditions) do |*args|
1799
</code></li>
1800
                
1801
                <li class="post-context-line"><code>            env[&#x27;sinatra.route&#x27;] = block.instance_variable_get(:@route_name)
1802
</code></li>
1803
                
1804
                <li class="post-context-line"><code>            route_eval { block[*args] }
1805
</code></li>
1806
                
1807
                <li class="post-context-line"><code>          end
1808
</code></li>
1809
                
1810
                <li class="post-context-line"><code>        end
1811
</code></li>
1812
                
1813
                <li class="post-context-line"><code>      end
1814
</code></li>
1815
                
1816
                <li class="post-context-line"><code>
1817
</code></li>
1818
                
1819
              </ol>
1820
              
1821
              <div class="clear"></div>
1822
            </li>
1823

    
1824
          
1825

    
1826
        
1827
      
1828
          
1829

    
1830
            <li class="frame-info framework">
1831
              <code>&#x2F;usr&#x2F;lib&#x2F;ruby&#x2F;gems&#x2F;1.8&#x2F;gems&#x2F;sinatra-1.4.3&#x2F;lib&#x2F;sinatra&#x2F;base.rb</code> in
1832
                <code><strong>route!</strong></code>
1833
            </li>
1834

    
1835
            <li class="code framework">
1836
              
1837
              <ol start="940"
1838
                  class="pre-context" id="pre-23"
1839
                  onclick="toggle(23);">
1840
                
1841
                <li class="pre-context-line"><code>      filter! type, base.superclass if base.superclass.respond_to?(:filters)
1842
</code></li>
1843
                
1844
                <li class="pre-context-line"><code>      base.filters[type].each { |args| process_route(*args) }
1845
</code></li>
1846
                
1847
                <li class="pre-context-line"><code>    end
1848
</code></li>
1849
                
1850
                <li class="pre-context-line"><code>
1851
</code></li>
1852
                
1853
                <li class="pre-context-line"><code>    # Run routes defined on the class and all superclasses.
1854
</code></li>
1855
                
1856
                <li class="pre-context-line"><code>    def route!(base = settings, pass_block = nil)
1857
</code></li>
1858
                
1859
                <li class="pre-context-line"><code>      if routes = base.routes[@request.request_method]
1860
</code></li>
1861
                
1862
              </ol>
1863
              
1864

    
1865
              <ol start="947" class="context" id="23"
1866
                  onclick="toggle(23);">
1867
                <li class="context-line" id="context-23"><code>        routes.each do |pattern, keys, conditions, block|</code></li>
1868
              </ol>
1869

    
1870
              
1871
              <ol start="948" class="post-context"
1872
                  id="post-23" onclick="toggle(23);">
1873
                
1874
                <li class="post-context-line"><code>          pass_block = process_route(pattern, keys, conditions) do |*args|
1875
</code></li>
1876
                
1877
                <li class="post-context-line"><code>            env[&#x27;sinatra.route&#x27;] = block.instance_variable_get(:@route_name)
1878
</code></li>
1879
                
1880
                <li class="post-context-line"><code>            route_eval { block[*args] }
1881
</code></li>
1882
                
1883
                <li class="post-context-line"><code>          end
1884
</code></li>
1885
                
1886
                <li class="post-context-line"><code>        end
1887
</code></li>
1888
                
1889
                <li class="post-context-line"><code>      end
1890
</code></li>
1891
                
1892
                <li class="post-context-line"><code>
1893
</code></li>
1894
                
1895
              </ol>
1896
              
1897
              <div class="clear"></div>
1898
            </li>
1899

    
1900
          
1901

    
1902
        
1903
      
1904
          
1905

    
1906
            <li class="frame-info framework">
1907
              <code>&#x2F;usr&#x2F;lib&#x2F;ruby&#x2F;gems&#x2F;1.8&#x2F;gems&#x2F;sinatra-1.4.3&#x2F;lib&#x2F;sinatra&#x2F;base.rb</code> in
1908
                <code><strong>dispatch!</strong></code>
1909
            </li>
1910

    
1911
            <li class="code framework">
1912
              
1913
              <ol start="1052"
1914
                  class="pre-context" id="pre-24"
1915
                  onclick="toggle(24);">
1916
                
1917
                <li class="pre-context-line"><code>    end
1918
</code></li>
1919
                
1920
                <li class="pre-context-line"><code>
1921
</code></li>
1922
                
1923
                <li class="pre-context-line"><code>    # Dispatch a request with error handling.
1924
</code></li>
1925
                
1926
                <li class="pre-context-line"><code>    def dispatch!
1927
</code></li>
1928
                
1929
                <li class="pre-context-line"><code>      invoke do
1930
</code></li>
1931
                
1932
                <li class="pre-context-line"><code>        static! if settings.static? &amp;&amp; (request.get? || request.head?)
1933
</code></li>
1934
                
1935
                <li class="pre-context-line"><code>        filter! :before
1936
</code></li>
1937
                
1938
              </ol>
1939
              
1940

    
1941
              <ol start="1059" class="context" id="24"
1942
                  onclick="toggle(24);">
1943
                <li class="context-line" id="context-24"><code>        route!</code></li>
1944
              </ol>
1945

    
1946
              
1947
              <ol start="1060" class="post-context"
1948
                  id="post-24" onclick="toggle(24);">
1949
                
1950
                <li class="post-context-line"><code>      end
1951
</code></li>
1952
                
1953
                <li class="post-context-line"><code>    rescue ::Exception =&gt; boom
1954
</code></li>
1955
                
1956
                <li class="post-context-line"><code>      invoke { handle_exception!(boom) }
1957
</code></li>
1958
                
1959
                <li class="post-context-line"><code>    ensure
1960
</code></li>
1961
                
1962
                <li class="post-context-line"><code>      begin
1963
</code></li>
1964
                
1965
                <li class="post-context-line"><code>        filter! :after unless env[&#x27;sinatra.static_file&#x27;]
1966
</code></li>
1967
                
1968
                <li class="post-context-line"><code>      rescue ::Exception =&gt; boom
1969
</code></li>
1970
                
1971
              </ol>
1972
              
1973
              <div class="clear"></div>
1974
            </li>
1975

    
1976
          
1977

    
1978
        
1979
      
1980
          
1981

    
1982
            <li class="frame-info framework">
1983
              <code>&#x2F;usr&#x2F;lib&#x2F;ruby&#x2F;gems&#x2F;1.8&#x2F;gems&#x2F;sinatra-1.4.3&#x2F;lib&#x2F;sinatra&#x2F;base.rb</code> in
1984
                <code><strong>invoke</strong></code>
1985
            </li>
1986

    
1987
            <li class="code framework">
1988
              
1989
              <ol start="1034"
1990
                  class="pre-context" id="pre-25"
1991
                  onclick="toggle(25);">
1992
                
1993
                <li class="pre-context-line"><code>    # Creates a Hash with indifferent access.
1994
</code></li>
1995
                
1996
                <li class="pre-context-line"><code>    def indifferent_hash
1997
</code></li>
1998
                
1999
                <li class="pre-context-line"><code>      Hash.new {|hash,key| hash[key.to_s] if Symbol === key }
2000
</code></li>
2001
                
2002
                <li class="pre-context-line"><code>    end
2003
</code></li>
2004
                
2005
                <li class="pre-context-line"><code>
2006
</code></li>
2007
                
2008
                <li class="pre-context-line"><code>    # Run the block with &#x27;throw :halt&#x27; support and apply result to the response.
2009
</code></li>
2010
                
2011
                <li class="pre-context-line"><code>    def invoke
2012
</code></li>
2013
                
2014
              </ol>
2015
              
2016

    
2017
              <ol start="1041" class="context" id="25"
2018
                  onclick="toggle(25);">
2019
                <li class="context-line" id="context-25"><code>      res = catch(:halt) { yield }</code></li>
2020
              </ol>
2021

    
2022
              
2023
              <ol start="1042" class="post-context"
2024
                  id="post-25" onclick="toggle(25);">
2025
                
2026
                <li class="post-context-line"><code>      res = [res] if Fixnum === res or String === res
2027
</code></li>
2028
                
2029
                <li class="post-context-line"><code>      if Array === res and Fixnum === res.first
2030
</code></li>
2031
                
2032
                <li class="post-context-line"><code>        res = res.dup
2033
</code></li>
2034
                
2035
                <li class="post-context-line"><code>        status(res.shift)
2036
</code></li>
2037
                
2038
                <li class="post-context-line"><code>        body(res.pop)
2039
</code></li>
2040
                
2041
                <li class="post-context-line"><code>        headers(*res)
2042
</code></li>
2043
                
2044
                <li class="post-context-line"><code>      elsif res.respond_to? :each
2045
</code></li>
2046
                
2047
              </ol>
2048
              
2049
              <div class="clear"></div>
2050
            </li>
2051

    
2052
          
2053

    
2054
        
2055
      
2056
          
2057

    
2058
            <li class="frame-info framework">
2059
              <code>&#x2F;usr&#x2F;lib&#x2F;ruby&#x2F;gems&#x2F;1.8&#x2F;gems&#x2F;sinatra-1.4.3&#x2F;lib&#x2F;sinatra&#x2F;base.rb</code> in
2060
                <code><strong>catch</strong></code>
2061
            </li>
2062

    
2063
            <li class="code framework">
2064
              
2065
              <ol start="1034"
2066
                  class="pre-context" id="pre-26"
2067
                  onclick="toggle(26);">
2068
                
2069
                <li class="pre-context-line"><code>    # Creates a Hash with indifferent access.
2070
</code></li>
2071
                
2072
                <li class="pre-context-line"><code>    def indifferent_hash
2073
</code></li>
2074
                
2075
                <li class="pre-context-line"><code>      Hash.new {|hash,key| hash[key.to_s] if Symbol === key }
2076
</code></li>
2077
                
2078
                <li class="pre-context-line"><code>    end
2079
</code></li>
2080
                
2081
                <li class="pre-context-line"><code>
2082
</code></li>
2083
                
2084
                <li class="pre-context-line"><code>    # Run the block with &#x27;throw :halt&#x27; support and apply result to the response.
2085
</code></li>
2086
                
2087
                <li class="pre-context-line"><code>    def invoke
2088
</code></li>
2089
                
2090
              </ol>
2091
              
2092

    
2093
              <ol start="1041" class="context" id="26"
2094
                  onclick="toggle(26);">
2095
                <li class="context-line" id="context-26"><code>      res = catch(:halt) { yield }</code></li>
2096
              </ol>
2097

    
2098
              
2099
              <ol start="1042" class="post-context"
2100
                  id="post-26" onclick="toggle(26);">
2101
                
2102
                <li class="post-context-line"><code>      res = [res] if Fixnum === res or String === res
2103
</code></li>
2104
                
2105
                <li class="post-context-line"><code>      if Array === res and Fixnum === res.first
2106
</code></li>
2107
                
2108
                <li class="post-context-line"><code>        res = res.dup
2109
</code></li>
2110
                
2111
                <li class="post-context-line"><code>        status(res.shift)
2112
</code></li>
2113
                
2114
                <li class="post-context-line"><code>        body(res.pop)
2115
</code></li>
2116
                
2117
                <li class="post-context-line"><code>        headers(*res)
2118
</code></li>
2119
                
2120
                <li class="post-context-line"><code>      elsif res.respond_to? :each
2121
</code></li>
2122
                
2123
              </ol>
2124
              
2125
              <div class="clear"></div>
2126
            </li>
2127

    
2128
          
2129

    
2130
        
2131
      
2132
          
2133

    
2134
            <li class="frame-info framework">
2135
              <code>&#x2F;usr&#x2F;lib&#x2F;ruby&#x2F;gems&#x2F;1.8&#x2F;gems&#x2F;sinatra-1.4.3&#x2F;lib&#x2F;sinatra&#x2F;base.rb</code> in
2136
                <code><strong>invoke</strong></code>
2137
            </li>
2138

    
2139
            <li class="code framework">
2140
              
2141
              <ol start="1034"
2142
                  class="pre-context" id="pre-27"
2143
                  onclick="toggle(27);">
2144
                
2145
                <li class="pre-context-line"><code>    # Creates a Hash with indifferent access.
2146
</code></li>
2147
                
2148
                <li class="pre-context-line"><code>    def indifferent_hash
2149
</code></li>
2150
                
2151
                <li class="pre-context-line"><code>      Hash.new {|hash,key| hash[key.to_s] if Symbol === key }
2152
</code></li>
2153
                
2154
                <li class="pre-context-line"><code>    end
2155
</code></li>
2156
                
2157
                <li class="pre-context-line"><code>
2158
</code></li>
2159
                
2160
                <li class="pre-context-line"><code>    # Run the block with &#x27;throw :halt&#x27; support and apply result to the response.
2161
</code></li>
2162
                
2163
                <li class="pre-context-line"><code>    def invoke
2164
</code></li>
2165
                
2166
              </ol>
2167
              
2168

    
2169
              <ol start="1041" class="context" id="27"
2170
                  onclick="toggle(27);">
2171
                <li class="context-line" id="context-27"><code>      res = catch(:halt) { yield }</code></li>
2172
              </ol>
2173

    
2174
              
2175
              <ol start="1042" class="post-context"
2176
                  id="post-27" onclick="toggle(27);">
2177
                
2178
                <li class="post-context-line"><code>      res = [res] if Fixnum === res or String === res
2179
</code></li>
2180
                
2181
                <li class="post-context-line"><code>      if Array === res and Fixnum === res.first
2182
</code></li>
2183
                
2184
                <li class="post-context-line"><code>        res = res.dup
2185
</code></li>
2186
                
2187
                <li class="post-context-line"><code>        status(res.shift)
2188
</code></li>
2189
                
2190
                <li class="post-context-line"><code>        body(res.pop)
2191
</code></li>
2192
                
2193
                <li class="post-context-line"><code>        headers(*res)
2194
</code></li>
2195
                
2196
                <li class="post-context-line"><code>      elsif res.respond_to? :each
2197
</code></li>
2198
                
2199
              </ol>
2200
              
2201
              <div class="clear"></div>
2202
            </li>
2203

    
2204
          
2205

    
2206
        
2207
      
2208
          
2209

    
2210
            <li class="frame-info framework">
2211
              <code>&#x2F;usr&#x2F;lib&#x2F;ruby&#x2F;gems&#x2F;1.8&#x2F;gems&#x2F;sinatra-1.4.3&#x2F;lib&#x2F;sinatra&#x2F;base.rb</code> in
2212
                <code><strong>dispatch!</strong></code>
2213
            </li>
2214

    
2215
            <li class="code framework">
2216
              
2217
              <ol start="1049"
2218
                  class="pre-context" id="pre-28"
2219
                  onclick="toggle(28);">
2220
                
2221
                <li class="pre-context-line"><code>        body res
2222
</code></li>
2223
                
2224
                <li class="pre-context-line"><code>      end
2225
</code></li>
2226
                
2227
                <li class="pre-context-line"><code>      nil # avoid double setting the same response tuple twice
2228
</code></li>
2229
                
2230
                <li class="pre-context-line"><code>    end
2231
</code></li>
2232
                
2233
                <li class="pre-context-line"><code>
2234
</code></li>
2235
                
2236
                <li class="pre-context-line"><code>    # Dispatch a request with error handling.
2237
</code></li>
2238
                
2239
                <li class="pre-context-line"><code>    def dispatch!
2240
</code></li>
2241
                
2242
              </ol>
2243
              
2244

    
2245
              <ol start="1056" class="context" id="28"
2246
                  onclick="toggle(28);">
2247
                <li class="context-line" id="context-28"><code>      invoke do</code></li>
2248
              </ol>
2249

    
2250
              
2251
              <ol start="1057" class="post-context"
2252
                  id="post-28" onclick="toggle(28);">
2253
                
2254
                <li class="post-context-line"><code>        static! if settings.static? &amp;&amp; (request.get? || request.head?)
2255
</code></li>
2256
                
2257
                <li class="post-context-line"><code>        filter! :before
2258
</code></li>
2259
                
2260
                <li class="post-context-line"><code>        route!
2261
</code></li>
2262
                
2263
                <li class="post-context-line"><code>      end
2264
</code></li>
2265
                
2266
                <li class="post-context-line"><code>    rescue ::Exception =&gt; boom
2267
</code></li>
2268
                
2269
                <li class="post-context-line"><code>      invoke { handle_exception!(boom) }
2270
</code></li>
2271
                
2272
                <li class="post-context-line"><code>    ensure
2273
</code></li>
2274
                
2275
              </ol>
2276
              
2277
              <div class="clear"></div>
2278
            </li>
2279

    
2280
          
2281

    
2282
        
2283
      
2284
          
2285

    
2286
            <li class="frame-info framework">
2287
              <code>&#x2F;usr&#x2F;lib&#x2F;ruby&#x2F;gems&#x2F;1.8&#x2F;gems&#x2F;sinatra-1.4.3&#x2F;lib&#x2F;sinatra&#x2F;base.rb</code> in
2288
                <code><strong>call!</strong></code>
2289
            </li>
2290

    
2291
            <li class="code framework">
2292
              
2293
              <ol start="875"
2294
                  class="pre-context" id="pre-29"
2295
                  onclick="toggle(29);">
2296
                
2297
                <li class="pre-context-line"><code>      @request  = Request.new(env)
2298
</code></li>
2299
                
2300
                <li class="pre-context-line"><code>      @response = Response.new
2301
</code></li>
2302
                
2303
                <li class="pre-context-line"><code>      @params   = indifferent_params(@request.params)
2304
</code></li>
2305
                
2306
                <li class="pre-context-line"><code>      template_cache.clear if settings.reload_templates
2307
</code></li>
2308
                
2309
                <li class="pre-context-line"><code>      force_encoding(@params)
2310
</code></li>
2311
                
2312
                <li class="pre-context-line"><code>
2313
</code></li>
2314
                
2315
                <li class="pre-context-line"><code>      @response[&#x27;Content-Type&#x27;] = nil
2316
</code></li>
2317
                
2318
              </ol>
2319
              
2320

    
2321
              <ol start="882" class="context" id="29"
2322
                  onclick="toggle(29);">
2323
                <li class="context-line" id="context-29"><code>      invoke { dispatch! }</code></li>
2324
              </ol>
2325

    
2326
              
2327
              <ol start="883" class="post-context"
2328
                  id="post-29" onclick="toggle(29);">
2329
                
2330
                <li class="post-context-line"><code>      invoke { error_block!(response.status) } unless @env[&#x27;sinatra.error&#x27;]
2331
</code></li>
2332
                
2333
                <li class="post-context-line"><code>
2334
</code></li>
2335
                
2336
                <li class="post-context-line"><code>      unless @response[&#x27;Content-Type&#x27;]
2337
</code></li>
2338
                
2339
                <li class="post-context-line"><code>        if Array === body and body[0].respond_to? :content_type
2340
</code></li>
2341
                
2342
                <li class="post-context-line"><code>          content_type body[0].content_type
2343
</code></li>
2344
                
2345
                <li class="post-context-line"><code>        else
2346
</code></li>
2347
                
2348
                <li class="post-context-line"><code>          content_type :html
2349
</code></li>
2350
                
2351
              </ol>
2352
              
2353
              <div class="clear"></div>
2354
            </li>
2355

    
2356
          
2357

    
2358
        
2359
      
2360
          
2361

    
2362
            <li class="frame-info framework">
2363
              <code>&#x2F;usr&#x2F;lib&#x2F;ruby&#x2F;gems&#x2F;1.8&#x2F;gems&#x2F;sinatra-1.4.3&#x2F;lib&#x2F;sinatra&#x2F;base.rb</code> in
2364
                <code><strong>invoke</strong></code>
2365
            </li>
2366

    
2367
            <li class="code framework">
2368
              
2369
              <ol start="1034"
2370
                  class="pre-context" id="pre-30"
2371
                  onclick="toggle(30);">
2372
                
2373
                <li class="pre-context-line"><code>    # Creates a Hash with indifferent access.
2374
</code></li>
2375
                
2376
                <li class="pre-context-line"><code>    def indifferent_hash
2377
</code></li>
2378
                
2379
                <li class="pre-context-line"><code>      Hash.new {|hash,key| hash[key.to_s] if Symbol === key }
2380
</code></li>
2381
                
2382
                <li class="pre-context-line"><code>    end
2383
</code></li>
2384
                
2385
                <li class="pre-context-line"><code>
2386
</code></li>
2387
                
2388
                <li class="pre-context-line"><code>    # Run the block with &#x27;throw :halt&#x27; support and apply result to the response.
2389
</code></li>
2390
                
2391
                <li class="pre-context-line"><code>    def invoke
2392
</code></li>
2393
                
2394
              </ol>
2395
              
2396

    
2397
              <ol start="1041" class="context" id="30"
2398
                  onclick="toggle(30);">
2399
                <li class="context-line" id="context-30"><code>      res = catch(:halt) { yield }</code></li>
2400
              </ol>
2401

    
2402
              
2403
              <ol start="1042" class="post-context"
2404
                  id="post-30" onclick="toggle(30);">
2405
                
2406
                <li class="post-context-line"><code>      res = [res] if Fixnum === res or String === res
2407
</code></li>
2408
                
2409
                <li class="post-context-line"><code>      if Array === res and Fixnum === res.first
2410
</code></li>
2411
                
2412
                <li class="post-context-line"><code>        res = res.dup
2413
</code></li>
2414
                
2415
                <li class="post-context-line"><code>        status(res.shift)
2416
</code></li>
2417
                
2418
                <li class="post-context-line"><code>        body(res.pop)
2419
</code></li>
2420
                
2421
                <li class="post-context-line"><code>        headers(*res)
2422
</code></li>
2423
                
2424
                <li class="post-context-line"><code>      elsif res.respond_to? :each
2425
</code></li>
2426
                
2427
              </ol>
2428
              
2429
              <div class="clear"></div>
2430
            </li>
2431

    
2432
          
2433

    
2434
        
2435
      
2436
          
2437

    
2438
            <li class="frame-info framework">
2439
              <code>&#x2F;usr&#x2F;lib&#x2F;ruby&#x2F;gems&#x2F;1.8&#x2F;gems&#x2F;sinatra-1.4.3&#x2F;lib&#x2F;sinatra&#x2F;base.rb</code> in
2440
                <code><strong>catch</strong></code>
2441
            </li>
2442

    
2443
            <li class="code framework">
2444
              
2445
              <ol start="1034"
2446
                  class="pre-context" id="pre-31"
2447
                  onclick="toggle(31);">
2448
                
2449
                <li class="pre-context-line"><code>    # Creates a Hash with indifferent access.
2450
</code></li>
2451
                
2452
                <li class="pre-context-line"><code>    def indifferent_hash
2453
</code></li>
2454
                
2455
                <li class="pre-context-line"><code>      Hash.new {|hash,key| hash[key.to_s] if Symbol === key }
2456
</code></li>
2457
                
2458
                <li class="pre-context-line"><code>    end
2459
</code></li>
2460
                
2461
                <li class="pre-context-line"><code>
2462
</code></li>
2463
                
2464
                <li class="pre-context-line"><code>    # Run the block with &#x27;throw :halt&#x27; support and apply result to the response.
2465
</code></li>
2466
                
2467
                <li class="pre-context-line"><code>    def invoke
2468
</code></li>
2469
                
2470
              </ol>
2471
              
2472

    
2473
              <ol start="1041" class="context" id="31"
2474
                  onclick="toggle(31);">
2475
                <li class="context-line" id="context-31"><code>      res = catch(:halt) { yield }</code></li>
2476
              </ol>
2477

    
2478
              
2479
              <ol start="1042" class="post-context"
2480
                  id="post-31" onclick="toggle(31);">
2481
                
2482
                <li class="post-context-line"><code>      res = [res] if Fixnum === res or String === res
2483
</code></li>
2484
                
2485
                <li class="post-context-line"><code>      if Array === res and Fixnum === res.first
2486
</code></li>
2487
                
2488
                <li class="post-context-line"><code>        res = res.dup
2489
</code></li>
2490
                
2491
                <li class="post-context-line"><code>        status(res.shift)
2492
</code></li>
2493
                
2494
                <li class="post-context-line"><code>        body(res.pop)
2495
</code></li>
2496
                
2497
                <li class="post-context-line"><code>        headers(*res)
2498
</code></li>
2499
                
2500
                <li class="post-context-line"><code>      elsif res.respond_to? :each
2501
</code></li>
2502
                
2503
              </ol>
2504
              
2505
              <div class="clear"></div>
2506
            </li>
2507

    
2508
          
2509

    
2510
        
2511
      
2512
          
2513

    
2514
            <li class="frame-info framework">
2515
              <code>&#x2F;usr&#x2F;lib&#x2F;ruby&#x2F;gems&#x2F;1.8&#x2F;gems&#x2F;sinatra-1.4.3&#x2F;lib&#x2F;sinatra&#x2F;base.rb</code> in
2516
                <code><strong>invoke</strong></code>
2517
            </li>
2518

    
2519
            <li class="code framework">
2520
              
2521
              <ol start="1034"
2522
                  class="pre-context" id="pre-32"
2523
                  onclick="toggle(32);">
2524
                
2525
                <li class="pre-context-line"><code>    # Creates a Hash with indifferent access.
2526
</code></li>
2527
                
2528
                <li class="pre-context-line"><code>    def indifferent_hash
2529
</code></li>
2530
                
2531
                <li class="pre-context-line"><code>      Hash.new {|hash,key| hash[key.to_s] if Symbol === key }
2532
</code></li>
2533
                
2534
                <li class="pre-context-line"><code>    end
2535
</code></li>
2536
                
2537
                <li class="pre-context-line"><code>
2538
</code></li>
2539
                
2540
                <li class="pre-context-line"><code>    # Run the block with &#x27;throw :halt&#x27; support and apply result to the response.
2541
</code></li>
2542
                
2543
                <li class="pre-context-line"><code>    def invoke
2544
</code></li>
2545
                
2546
              </ol>
2547
              
2548

    
2549
              <ol start="1041" class="context" id="32"
2550
                  onclick="toggle(32);">
2551
                <li class="context-line" id="context-32"><code>      res = catch(:halt) { yield }</code></li>
2552
              </ol>
2553

    
2554
              
2555
              <ol start="1042" class="post-context"
2556
                  id="post-32" onclick="toggle(32);">
2557
                
2558
                <li class="post-context-line"><code>      res = [res] if Fixnum === res or String === res
2559
</code></li>
2560
                
2561
                <li class="post-context-line"><code>      if Array === res and Fixnum === res.first
2562
</code></li>
2563
                
2564
                <li class="post-context-line"><code>        res = res.dup
2565
</code></li>
2566
                
2567
                <li class="post-context-line"><code>        status(res.shift)
2568
</code></li>
2569
                
2570
                <li class="post-context-line"><code>        body(res.pop)
2571
</code></li>
2572
                
2573
                <li class="post-context-line"><code>        headers(*res)
2574
</code></li>
2575
                
2576
                <li class="post-context-line"><code>      elsif res.respond_to? :each
2577
</code></li>
2578
                
2579
              </ol>
2580
              
2581
              <div class="clear"></div>
2582
            </li>
2583

    
2584
          
2585

    
2586
        
2587
      
2588
          
2589

    
2590
            <li class="frame-info framework">
2591
              <code>&#x2F;usr&#x2F;lib&#x2F;ruby&#x2F;gems&#x2F;1.8&#x2F;gems&#x2F;sinatra-1.4.3&#x2F;lib&#x2F;sinatra&#x2F;base.rb</code> in
2592
                <code><strong>call!</strong></code>
2593
            </li>
2594

    
2595
            <li class="code framework">
2596
              
2597
              <ol start="875"
2598
                  class="pre-context" id="pre-33"
2599
                  onclick="toggle(33);">
2600
                
2601
                <li class="pre-context-line"><code>      @request  = Request.new(env)
2602
</code></li>
2603
                
2604
                <li class="pre-context-line"><code>      @response = Response.new
2605
</code></li>
2606
                
2607
                <li class="pre-context-line"><code>      @params   = indifferent_params(@request.params)
2608
</code></li>
2609
                
2610
                <li class="pre-context-line"><code>      template_cache.clear if settings.reload_templates
2611
</code></li>
2612
                
2613
                <li class="pre-context-line"><code>      force_encoding(@params)
2614
</code></li>
2615
                
2616
                <li class="pre-context-line"><code>
2617
</code></li>
2618
                
2619
                <li class="pre-context-line"><code>      @response[&#x27;Content-Type&#x27;] = nil
2620
</code></li>
2621
                
2622
              </ol>
2623
              
2624

    
2625
              <ol start="882" class="context" id="33"
2626
                  onclick="toggle(33);">
2627
                <li class="context-line" id="context-33"><code>      invoke { dispatch! }</code></li>
2628
              </ol>
2629

    
2630
              
2631
              <ol start="883" class="post-context"
2632
                  id="post-33" onclick="toggle(33);">
2633
                
2634
                <li class="post-context-line"><code>      invoke { error_block!(response.status) } unless @env[&#x27;sinatra.error&#x27;]
2635
</code></li>
2636
                
2637
                <li class="post-context-line"><code>
2638
</code></li>
2639
                
2640
                <li class="post-context-line"><code>      unless @response[&#x27;Content-Type&#x27;]
2641
</code></li>
2642
                
2643
                <li class="post-context-line"><code>        if Array === body and body[0].respond_to? :content_type
2644
</code></li>
2645
                
2646
                <li class="post-context-line"><code>          content_type body[0].content_type
2647
</code></li>
2648
                
2649
                <li class="post-context-line"><code>        else
2650
</code></li>
2651
                
2652
                <li class="post-context-line"><code>          content_type :html
2653
</code></li>
2654
                
2655
              </ol>
2656
              
2657
              <div class="clear"></div>
2658
            </li>
2659

    
2660
          
2661

    
2662
        
2663
      
2664
          
2665

    
2666
            <li class="frame-info framework">
2667
              <code>&#x2F;usr&#x2F;lib&#x2F;ruby&#x2F;gems&#x2F;1.8&#x2F;gems&#x2F;sinatra-1.4.3&#x2F;lib&#x2F;sinatra&#x2F;base.rb</code> in
2668
                <code><strong>call</strong></code>
2669
            </li>
2670

    
2671
            <li class="code framework">
2672
              
2673
              <ol start="863"
2674
                  class="pre-context" id="pre-34"
2675
                  onclick="toggle(34);">
2676
                
2677
                <li class="pre-context-line"><code>      @app = app
2678
</code></li>
2679
                
2680
                <li class="pre-context-line"><code>      @template_cache = Tilt::Cache.new
2681
</code></li>
2682
                
2683
                <li class="pre-context-line"><code>      yield self if block_given?
2684
</code></li>
2685
                
2686
                <li class="pre-context-line"><code>    end
2687
</code></li>
2688
                
2689
                <li class="pre-context-line"><code>
2690
</code></li>
2691
                
2692
                <li class="pre-context-line"><code>    # Rack call interface.
2693
</code></li>
2694
                
2695
                <li class="pre-context-line"><code>    def call(env)
2696
</code></li>
2697
                
2698
              </ol>
2699
              
2700

    
2701
              <ol start="870" class="context" id="34"
2702
                  onclick="toggle(34);">
2703
                <li class="context-line" id="context-34"><code>      dup.call!(env)</code></li>
2704
              </ol>
2705

    
2706
              
2707
              <ol start="871" class="post-context"
2708
                  id="post-34" onclick="toggle(34);">
2709
                
2710
                <li class="post-context-line"><code>    end
2711
</code></li>
2712
                
2713
                <li class="post-context-line"><code>
2714
</code></li>
2715
                
2716
                <li class="post-context-line"><code>    def call!(env) # :nodoc:
2717
</code></li>
2718
                
2719
                <li class="post-context-line"><code>      @env      = env
2720
</code></li>
2721
                
2722
                <li class="post-context-line"><code>      @request  = Request.new(env)
2723
</code></li>
2724
                
2725
                <li class="post-context-line"><code>      @response = Response.new
2726
</code></li>
2727
                
2728
                <li class="post-context-line"><code>      @params   = indifferent_params(@request.params)
2729
</code></li>
2730
                
2731
              </ol>
2732
              
2733
              <div class="clear"></div>
2734
            </li>
2735

    
2736
          
2737

    
2738
        
2739
      
2740
          
2741

    
2742
            <li class="frame-info system">
2743
              <code>&#x2F;usr&#x2F;lib&#x2F;ruby&#x2F;gems&#x2F;1.8&#x2F;gems&#x2F;rack-1.5.2&#x2F;lib&#x2F;rack&#x2F;session&#x2F;abstract&#x2F;id.rb</code> in
2744
                <code><strong>context</strong></code>
2745
            </li>
2746

    
2747
            <li class="code system">
2748
              
2749
              <ol start="218"
2750
                  class="pre-context" id="pre-35"
2751
                  onclick="toggle(35);">
2752
                
2753
                <li class="pre-context-line"><code>
2754
</code></li>
2755
                
2756
                <li class="pre-context-line"><code>        def call(env)
2757
</code></li>
2758
                
2759
                <li class="pre-context-line"><code>          context(env)
2760
</code></li>
2761
                
2762
                <li class="pre-context-line"><code>        end
2763
</code></li>
2764
                
2765
                <li class="pre-context-line"><code>
2766
</code></li>
2767
                
2768
                <li class="pre-context-line"><code>        def context(env, app=@app)
2769
</code></li>
2770
                
2771
                <li class="pre-context-line"><code>          prepare_session(env)
2772
</code></li>
2773
                
2774
              </ol>
2775
              
2776

    
2777
              <ol start="225" class="context" id="35"
2778
                  onclick="toggle(35);">
2779
                <li class="context-line" id="context-35"><code>          status, headers, body = app.call(env)</code></li>
2780
              </ol>
2781

    
2782
              
2783
              <ol start="226" class="post-context"
2784
                  id="post-35" onclick="toggle(35);">
2785
                
2786
                <li class="post-context-line"><code>          commit_session(env, status, headers, body)
2787
</code></li>
2788
                
2789
                <li class="post-context-line"><code>        end
2790
</code></li>
2791
                
2792
                <li class="post-context-line"><code>
2793
</code></li>
2794
                
2795
                <li class="post-context-line"><code>        private
2796
</code></li>
2797
                
2798
                <li class="post-context-line"><code>
2799
</code></li>
2800
                
2801
                <li class="post-context-line"><code>        def initialize_sid
2802
</code></li>
2803
                
2804
                <li class="post-context-line"><code>          @sidbits = @default_options[:sidbits]
2805
</code></li>
2806
                
2807
              </ol>
2808
              
2809
              <div class="clear"></div>
2810
            </li>
2811

    
2812
          
2813

    
2814
        
2815
      
2816
          
2817

    
2818
            <li class="frame-info system">
2819
              <code>&#x2F;usr&#x2F;lib&#x2F;ruby&#x2F;gems&#x2F;1.8&#x2F;gems&#x2F;rack-1.5.2&#x2F;lib&#x2F;rack&#x2F;session&#x2F;abstract&#x2F;id.rb</code> in
2820
                <code><strong>call</strong></code>
2821
            </li>
2822

    
2823
            <li class="code system">
2824
              
2825
              <ol start="213"
2826
                  class="pre-context" id="pre-36"
2827
                  onclick="toggle(36);">
2828
                
2829
                <li class="pre-context-line"><code>          @default_options = self.class::DEFAULT_OPTIONS.merge(options)
2830
</code></li>
2831
                
2832
                <li class="pre-context-line"><code>          @key = @default_options.delete(:key)
2833
</code></li>
2834
                
2835
                <li class="pre-context-line"><code>          @cookie_only = @default_options.delete(:cookie_only)
2836
</code></li>
2837
                
2838
                <li class="pre-context-line"><code>          initialize_sid
2839
</code></li>
2840
                
2841
                <li class="pre-context-line"><code>        end
2842
</code></li>
2843
                
2844
                <li class="pre-context-line"><code>
2845
</code></li>
2846
                
2847
                <li class="pre-context-line"><code>        def call(env)
2848
</code></li>
2849
                
2850
              </ol>
2851
              
2852

    
2853
              <ol start="220" class="context" id="36"
2854
                  onclick="toggle(36);">
2855
                <li class="context-line" id="context-36"><code>          context(env)</code></li>
2856
              </ol>
2857

    
2858
              
2859
              <ol start="221" class="post-context"
2860
                  id="post-36" onclick="toggle(36);">
2861
                
2862
                <li class="post-context-line"><code>        end
2863
</code></li>
2864
                
2865
                <li class="post-context-line"><code>
2866
</code></li>
2867
                
2868
                <li class="post-context-line"><code>        def context(env, app=@app)
2869
</code></li>
2870
                
2871
                <li class="post-context-line"><code>          prepare_session(env)
2872
</code></li>
2873
                
2874
                <li class="post-context-line"><code>          status, headers, body = app.call(env)
2875
</code></li>
2876
                
2877
                <li class="post-context-line"><code>          commit_session(env, status, headers, body)
2878
</code></li>
2879
                
2880
                <li class="post-context-line"><code>        end
2881
</code></li>
2882
                
2883
              </ol>
2884
              
2885
              <div class="clear"></div>
2886
            </li>
2887

    
2888
          
2889

    
2890
        
2891
      
2892
          
2893

    
2894
            <li class="frame-info system">
2895
              <code>&#x2F;usr&#x2F;lib&#x2F;ruby&#x2F;gems&#x2F;1.8&#x2F;gems&#x2F;rack-1.5.2&#x2F;lib&#x2F;rack&#x2F;commonlogger.rb</code> in
2896
                <code><strong>call_without_check</strong></code>
2897
            </li>
2898

    
2899
            <li class="code system">
2900
              
2901
              <ol start="26"
2902
                  class="pre-context" id="pre-37"
2903
                  onclick="toggle(37);">
2904
                
2905
                <li class="pre-context-line"><code>    def initialize(app, logger=nil)
2906
</code></li>
2907
                
2908
                <li class="pre-context-line"><code>      @app = app
2909
</code></li>
2910
                
2911
                <li class="pre-context-line"><code>      @logger = logger
2912
</code></li>
2913
                
2914
                <li class="pre-context-line"><code>    end
2915
</code></li>
2916
                
2917
                <li class="pre-context-line"><code>
2918
</code></li>
2919
                
2920
                <li class="pre-context-line"><code>    def call(env)
2921
</code></li>
2922
                
2923
                <li class="pre-context-line"><code>      began_at = Time.now
2924
</code></li>
2925
                
2926
              </ol>
2927
              
2928

    
2929
              <ol start="33" class="context" id="37"
2930
                  onclick="toggle(37);">
2931
                <li class="context-line" id="context-37"><code>      status, header, body = @app.call(env)</code></li>
2932
              </ol>
2933

    
2934
              
2935
              <ol start="34" class="post-context"
2936
                  id="post-37" onclick="toggle(37);">
2937
                
2938
                <li class="post-context-line"><code>      header = Utils::HeaderHash.new(header)
2939
</code></li>
2940
                
2941
                <li class="post-context-line"><code>      body = BodyProxy.new(body) { log(env, status, header, began_at) }
2942
</code></li>
2943
                
2944
                <li class="post-context-line"><code>      [status, header, body]
2945
</code></li>
2946
                
2947
                <li class="post-context-line"><code>    end
2948
</code></li>
2949
                
2950
                <li class="post-context-line"><code>
2951
</code></li>
2952
                
2953
                <li class="post-context-line"><code>    private
2954
</code></li>
2955
                
2956
                <li class="post-context-line"><code>
2957
</code></li>
2958
                
2959
              </ol>
2960
              
2961
              <div class="clear"></div>
2962
            </li>
2963

    
2964
          
2965

    
2966
        
2967
      
2968
          
2969

    
2970
            <li class="frame-info framework">
2971
              <code>&#x2F;usr&#x2F;lib&#x2F;ruby&#x2F;gems&#x2F;1.8&#x2F;gems&#x2F;sinatra-1.4.3&#x2F;lib&#x2F;sinatra&#x2F;base.rb</code> in
2972
                <code><strong>call</strong></code>
2973
            </li>
2974

    
2975
            <li class="code framework">
2976
              
2977
              <ol start="205"
2978
                  class="pre-context" id="pre-38"
2979
                  onclick="toggle(38);">
2980
                
2981
                <li class="pre-context-line"><code>      env[&#x27;sinatra.commonlogger&#x27;] ? @app.call(env) : super
2982
</code></li>
2983
                
2984
                <li class="pre-context-line"><code>    end
2985
</code></li>
2986
                
2987
                <li class="pre-context-line"><code>
2988
</code></li>
2989
                
2990
                <li class="pre-context-line"><code>    superclass.class_eval do
2991
</code></li>
2992
                
2993
                <li class="pre-context-line"><code>      alias call_without_check call unless method_defined? :call_without_check
2994
</code></li>
2995
                
2996
                <li class="pre-context-line"><code>      def call(env)
2997
</code></li>
2998
                
2999
                <li class="pre-context-line"><code>        env[&#x27;sinatra.commonlogger&#x27;] = true
3000
</code></li>
3001
                
3002
              </ol>
3003
              
3004

    
3005
              <ol start="212" class="context" id="38"
3006
                  onclick="toggle(38);">
3007
                <li class="context-line" id="context-38"><code>        call_without_check(env)</code></li>
3008
              </ol>
3009

    
3010
              
3011
              <ol start="213" class="post-context"
3012
                  id="post-38" onclick="toggle(38);">
3013
                
3014
                <li class="post-context-line"><code>      end
3015
</code></li>
3016
                
3017
                <li class="post-context-line"><code>    end
3018
</code></li>
3019
                
3020
                <li class="post-context-line"><code>  end
3021
</code></li>
3022
                
3023
                <li class="post-context-line"><code>
3024
</code></li>
3025
                
3026
                <li class="post-context-line"><code>  class NotFound &lt; NameError #:nodoc:
3027
</code></li>
3028
                
3029
                <li class="post-context-line"><code>    def http_status; 404 end
3030
</code></li>
3031
                
3032
                <li class="post-context-line"><code>  end
3033
</code></li>
3034
                
3035
              </ol>
3036
              
3037
              <div class="clear"></div>
3038
            </li>
3039

    
3040
          
3041

    
3042
        
3043
      
3044
          
3045

    
3046
            <li class="frame-info system">
3047
              <code>&#x2F;usr&#x2F;lib&#x2F;ruby&#x2F;gems&#x2F;1.8&#x2F;gems&#x2F;rack-protection-1.5.0&#x2F;lib&#x2F;rack&#x2F;protection&#x2F;xss_header.rb</code> in
3048
                <code><strong>call</strong></code>
3049
            </li>
3050

    
3051
            <li class="code system">
3052
              
3053
              <ol start="11"
3054
                  class="pre-context" id="pre-39"
3055
                  onclick="toggle(39);">
3056
                
3057
                <li class="pre-context-line"><code>    #
3058
</code></li>
3059
                
3060
                <li class="pre-context-line"><code>    # Options:
3061
</code></li>
3062
                
3063
                <li class="pre-context-line"><code>    # xss_mode:: How the browser should prevent the attack (default: :block)
3064
</code></li>
3065
                
3066
                <li class="pre-context-line"><code>    class XSSHeader &lt; Base
3067
</code></li>
3068
                
3069
                <li class="pre-context-line"><code>      default_options :xss_mode =&gt; :block, :nosniff =&gt; true
3070
</code></li>
3071
                
3072
                <li class="pre-context-line"><code>
3073
</code></li>
3074
                
3075
                <li class="pre-context-line"><code>      def call(env)
3076
</code></li>
3077
                
3078
              </ol>
3079
              
3080

    
3081
              <ol start="18" class="context" id="39"
3082
                  onclick="toggle(39);">
3083
                <li class="context-line" id="context-39"><code>        status, headers, body = @app.call(env)</code></li>
3084
              </ol>
3085

    
3086
              
3087
              <ol start="19" class="post-context"
3088
                  id="post-39" onclick="toggle(39);">
3089
                
3090
                <li class="post-context-line"><code>        headers[&#x27;X-XSS-Protection&#x27;]       ||= &quot;1; mode=#{options[:xss_mode]}&quot; if html? headers
3091
</code></li>
3092
                
3093
                <li class="post-context-line"><code>        headers[&#x27;X-Content-Type-Options&#x27;] ||= &#x27;nosniff&#x27;                       if options[:nosniff]
3094
</code></li>
3095
                
3096
                <li class="post-context-line"><code>        [status, headers, body]
3097
</code></li>
3098
                
3099
                <li class="post-context-line"><code>      end
3100
</code></li>
3101
                
3102
                <li class="post-context-line"><code>    end
3103
</code></li>
3104
                
3105
                <li class="post-context-line"><code>  end
3106
</code></li>
3107
                
3108
                <li class="post-context-line"><code>end
3109
</code></li>
3110
                
3111
              </ol>
3112
              
3113
              <div class="clear"></div>
3114
            </li>
3115

    
3116
          
3117

    
3118
        
3119
      
3120
          
3121

    
3122
            <li class="frame-info system">
3123
              <code>&#x2F;usr&#x2F;lib&#x2F;ruby&#x2F;gems&#x2F;1.8&#x2F;gems&#x2F;rack-protection-1.5.0&#x2F;lib&#x2F;rack&#x2F;protection&#x2F;path_traversal.rb</code> in
3124
                <code><strong>call</strong></code>
3125
            </li>
3126

    
3127
            <li class="code system">
3128
              
3129
              <ol start="9"
3130
                  class="pre-context" id="pre-40"
3131
                  onclick="toggle(40);">
3132
                
3133
                <li class="pre-context-line"><code>    #
3134
</code></li>
3135
                
3136
                <li class="pre-context-line"><code>    # Unescapes &#x27;&#x2F;&#x27; and &#x27;.&#x27;, expands +path_info+.
3137
</code></li>
3138
                
3139
                <li class="pre-context-line"><code>    # Thus &lt;tt&gt;GET &#x2F;foo&#x2F;%2e%2e%2fbar&lt;&#x2F;tt&gt; becomes &lt;tt&gt;GET &#x2F;bar&lt;&#x2F;tt&gt;.
3140
</code></li>
3141
                
3142
                <li class="pre-context-line"><code>    class PathTraversal &lt; Base
3143
</code></li>
3144
                
3145
                <li class="pre-context-line"><code>      def call(env)
3146
</code></li>
3147
                
3148
                <li class="pre-context-line"><code>        path_was         = env[&quot;PATH_INFO&quot;]
3149
</code></li>
3150
                
3151
                <li class="pre-context-line"><code>        env[&quot;PATH_INFO&quot;] = cleanup path_was if path_was &amp;&amp; !path_was.empty?
3152
</code></li>
3153
                
3154
              </ol>
3155
              
3156

    
3157
              <ol start="16" class="context" id="40"
3158
                  onclick="toggle(40);">
3159
                <li class="context-line" id="context-40"><code>        app.call env</code></li>
3160
              </ol>
3161

    
3162
              
3163
              <ol start="17" class="post-context"
3164
                  id="post-40" onclick="toggle(40);">
3165
                
3166
                <li class="post-context-line"><code>      ensure
3167
</code></li>
3168
                
3169
                <li class="post-context-line"><code>        env[&quot;PATH_INFO&quot;] = path_was
3170
</code></li>
3171
                
3172
                <li class="post-context-line"><code>      end
3173
</code></li>
3174
                
3175
                <li class="post-context-line"><code>
3176
</code></li>
3177
                
3178
                <li class="post-context-line"><code>      def cleanup(path)
3179
</code></li>
3180
                
3181
                <li class="post-context-line"><code>        parts     = []
3182
</code></li>
3183
                
3184
                <li class="post-context-line"><code>        unescaped = path.gsub(&#x27;%2e&#x27;, &#x27;.&#x27;).gsub(&#x27;%2f&#x27;, &#x27;&#x2F;&#x27;)
3185
</code></li>
3186
                
3187
              </ol>
3188
              
3189
              <div class="clear"></div>
3190
            </li>
3191

    
3192
          
3193

    
3194
        
3195
      
3196
          
3197

    
3198
            <li class="frame-info system">
3199
              <code>&#x2F;usr&#x2F;lib&#x2F;ruby&#x2F;gems&#x2F;1.8&#x2F;gems&#x2F;rack-protection-1.5.0&#x2F;lib&#x2F;rack&#x2F;protection&#x2F;json_csrf.rb</code> in
3200
                <code><strong>call</strong></code>
3201
            </li>
3202

    
3203
            <li class="code system">
3204
              
3205
              <ol start="11"
3206
                  class="pre-context" id="pre-41"
3207
                  onclick="toggle(41);">
3208
                
3209
                <li class="pre-context-line"><code>    # Array prototype has been patched to track data. Checks the referrer
3210
</code></li>
3211
                
3212
                <li class="pre-context-line"><code>    # even on GET requests if the content type is JSON.
3213
</code></li>
3214
                
3215
                <li class="pre-context-line"><code>    class JsonCsrf &lt; Base
3216
</code></li>
3217
                
3218
                <li class="pre-context-line"><code>      default_reaction :deny
3219
</code></li>
3220
                
3221
                <li class="pre-context-line"><code>
3222
</code></li>
3223
                
3224
                <li class="pre-context-line"><code>      def call(env)
3225
</code></li>
3226
                
3227
                <li class="pre-context-line"><code>        request               = Request.new(env)
3228
</code></li>
3229
                
3230
              </ol>
3231
              
3232

    
3233
              <ol start="18" class="context" id="41"
3234
                  onclick="toggle(41);">
3235
                <li class="context-line" id="context-41"><code>        status, headers, body = app.call(env)</code></li>
3236
              </ol>
3237

    
3238
              
3239
              <ol start="19" class="post-context"
3240
                  id="post-41" onclick="toggle(41);">
3241
                
3242
                <li class="post-context-line"><code>
3243
</code></li>
3244
                
3245
                <li class="post-context-line"><code>        if has_vector? request, headers
3246
</code></li>
3247
                
3248
                <li class="post-context-line"><code>          warn env, &quot;attack prevented by #{self.class}&quot;
3249
</code></li>
3250
                
3251
                <li class="post-context-line"><code>          react(env)
3252
</code></li>
3253
                
3254
                <li class="post-context-line"><code>        else
3255
</code></li>
3256
                
3257
                <li class="post-context-line"><code>          [status, headers, body]
3258
</code></li>
3259
                
3260
                <li class="post-context-line"><code>        end
3261
</code></li>
3262
                
3263
              </ol>
3264
              
3265
              <div class="clear"></div>
3266
            </li>
3267

    
3268
          
3269

    
3270
        
3271
      
3272
          
3273

    
3274
            <li class="frame-info system">
3275
              <code>&#x2F;usr&#x2F;lib&#x2F;ruby&#x2F;gems&#x2F;1.8&#x2F;gems&#x2F;rack-protection-1.5.0&#x2F;lib&#x2F;rack&#x2F;protection&#x2F;base.rb</code> in
3276
                <code><strong>call</strong></code>
3277
            </li>
3278

    
3279
            <li class="code system">
3280
              
3281
              <ol start="42"
3282
                  class="pre-context" id="pre-42"
3283
                  onclick="toggle(42);">
3284
                
3285
                <li class="pre-context-line"><code>      end
3286
</code></li>
3287
                
3288
                <li class="pre-context-line"><code>
3289
</code></li>
3290
                
3291
                <li class="pre-context-line"><code>      def call(env)
3292
</code></li>
3293
                
3294
                <li class="pre-context-line"><code>        unless accepts? env
3295
</code></li>
3296
                
3297
                <li class="pre-context-line"><code>          warn env, &quot;attack prevented by #{self.class}&quot;
3298
</code></li>
3299
                
3300
                <li class="pre-context-line"><code>          result = react env
3301
</code></li>
3302
                
3303
                <li class="pre-context-line"><code>        end
3304
</code></li>
3305
                
3306
              </ol>
3307
              
3308

    
3309
              <ol start="49" class="context" id="42"
3310
                  onclick="toggle(42);">
3311
                <li class="context-line" id="context-42"><code>        result or app.call(env)</code></li>
3312
              </ol>
3313

    
3314
              
3315
              <ol start="50" class="post-context"
3316
                  id="post-42" onclick="toggle(42);">
3317
                
3318
                <li class="post-context-line"><code>      end
3319
</code></li>
3320
                
3321
                <li class="post-context-line"><code>
3322
</code></li>
3323
                
3324
                <li class="post-context-line"><code>      def react(env)
3325
</code></li>
3326
                
3327
                <li class="post-context-line"><code>        result = send(options[:reaction], env)
3328
</code></li>
3329
                
3330
                <li class="post-context-line"><code>        result if Array === result and result.size == 3
3331
</code></li>
3332
                
3333
                <li class="post-context-line"><code>      end
3334
</code></li>
3335
                
3336
                <li class="post-context-line"><code>
3337
</code></li>
3338
                
3339
              </ol>
3340
              
3341
              <div class="clear"></div>
3342
            </li>
3343

    
3344
          
3345

    
3346
        
3347
      
3348
          
3349

    
3350
            <li class="frame-info system">
3351
              <code>&#x2F;usr&#x2F;lib&#x2F;ruby&#x2F;gems&#x2F;1.8&#x2F;gems&#x2F;rack-protection-1.5.0&#x2F;lib&#x2F;rack&#x2F;protection&#x2F;frame_options.rb</code> in
3352
                <code><strong>call</strong></code>
3353
            </li>
3354

    
3355
            <li class="code system">
3356
              
3357
              <ol start="24"
3358
                  class="pre-context" id="pre-43"
3359
                  onclick="toggle(43);">
3360
                
3361
                <li class="pre-context-line"><code>          frame_options = options[:frame_options]
3362
</code></li>
3363
                
3364
                <li class="pre-context-line"><code>          frame_options = options[:frame_options].to_s.upcase unless frame_options.respond_to? :to_str
3365
</code></li>
3366
                
3367
                <li class="pre-context-line"><code>          frame_options.to_str
3368
</code></li>
3369
                
3370
                <li class="pre-context-line"><code>        end
3371
</code></li>
3372
                
3373
                <li class="pre-context-line"><code>      end
3374
</code></li>
3375
                
3376
                <li class="pre-context-line"><code>
3377
</code></li>
3378
                
3379
                <li class="pre-context-line"><code>      def call(env)
3380
</code></li>
3381
                
3382
              </ol>
3383
              
3384

    
3385
              <ol start="31" class="context" id="43"
3386
                  onclick="toggle(43);">
3387
                <li class="context-line" id="context-43"><code>        status, headers, body        = @app.call(env)</code></li>
3388
              </ol>
3389

    
3390
              
3391
              <ol start="32" class="post-context"
3392
                  id="post-43" onclick="toggle(43);">
3393
                
3394
                <li class="post-context-line"><code>        headers[&#x27;X-Frame-Options&#x27;] ||= frame_options if html? headers
3395
</code></li>
3396
                
3397
                <li class="post-context-line"><code>        [status, headers, body]
3398
</code></li>
3399
                
3400
                <li class="post-context-line"><code>      end
3401
</code></li>
3402
                
3403
                <li class="post-context-line"><code>    end
3404
</code></li>
3405
                
3406
                <li class="post-context-line"><code>  end
3407
</code></li>
3408
                
3409
                <li class="post-context-line"><code>end
3410
</code></li>
3411
                
3412
              </ol>
3413
              
3414
              <div class="clear"></div>
3415
            </li>
3416

    
3417
          
3418

    
3419
        
3420
      
3421
          
3422

    
3423
            <li class="frame-info system">
3424
              <code>&#x2F;usr&#x2F;lib&#x2F;ruby&#x2F;gems&#x2F;1.8&#x2F;gems&#x2F;rack-1.5.2&#x2F;lib&#x2F;rack&#x2F;nulllogger.rb</code> in
3425
                <code><strong>call</strong></code>
3426
            </li>
3427

    
3428
            <li class="code system">
3429
              
3430
              <ol start="2"
3431
                  class="pre-context" id="pre-44"
3432
                  onclick="toggle(44);">
3433
                
3434
                <li class="pre-context-line"><code>  class NullLogger
3435
</code></li>
3436
                
3437
                <li class="pre-context-line"><code>    def initialize(app)
3438
</code></li>
3439
                
3440
                <li class="pre-context-line"><code>      @app = app
3441
</code></li>
3442
                
3443
                <li class="pre-context-line"><code>    end
3444
</code></li>
3445
                
3446
                <li class="pre-context-line"><code>
3447
</code></li>
3448
                
3449
                <li class="pre-context-line"><code>    def call(env)
3450
</code></li>
3451
                
3452
                <li class="pre-context-line"><code>      env[&#x27;rack.logger&#x27;] = self
3453
</code></li>
3454
                
3455
              </ol>
3456
              
3457

    
3458
              <ol start="9" class="context" id="44"
3459
                  onclick="toggle(44);">
3460
                <li class="context-line" id="context-44"><code>      @app.call(env)</code></li>
3461
              </ol>
3462

    
3463
              
3464
              <ol start="10" class="post-context"
3465
                  id="post-44" onclick="toggle(44);">
3466
                
3467
                <li class="post-context-line"><code>    end
3468
</code></li>
3469
                
3470
                <li class="post-context-line"><code>
3471
</code></li>
3472
                
3473
                <li class="post-context-line"><code>    def info(progname = nil, &amp;block);  end
3474
</code></li>
3475
                
3476
                <li class="post-context-line"><code>    def debug(progname = nil, &amp;block); end
3477
</code></li>
3478
                
3479
                <li class="post-context-line"><code>    def warn(progname = nil, &amp;block);  end
3480
</code></li>
3481
                
3482
                <li class="post-context-line"><code>    def error(progname = nil, &amp;block); end
3483
</code></li>
3484
                
3485
                <li class="post-context-line"><code>    def fatal(progname = nil, &amp;block); end
3486
</code></li>
3487
                
3488
              </ol>
3489
              
3490
              <div class="clear"></div>
3491
            </li>
3492

    
3493
          
3494

    
3495
        
3496
      
3497
          
3498

    
3499
            <li class="frame-info system">
3500
              <code>&#x2F;usr&#x2F;lib&#x2F;ruby&#x2F;gems&#x2F;1.8&#x2F;gems&#x2F;rack-1.5.2&#x2F;lib&#x2F;rack&#x2F;head.rb</code> in
3501
                <code><strong>call</strong></code>
3502
            </li>
3503

    
3504
            <li class="code system">
3505
              
3506
              <ol start="4"
3507
                  class="pre-context" id="pre-45"
3508
                  onclick="toggle(45);">
3509
                
3510
                <li class="pre-context-line"><code>  # Rack::Head returns an empty body for all HEAD requests. It leaves
3511
</code></li>
3512
                
3513
                <li class="pre-context-line"><code>  # all other requests unchanged.
3514
</code></li>
3515
                
3516
                <li class="pre-context-line"><code>  def initialize(app)
3517
</code></li>
3518
                
3519
                <li class="pre-context-line"><code>    @app = app
3520
</code></li>
3521
                
3522
                <li class="pre-context-line"><code>  end
3523
</code></li>
3524
                
3525
                <li class="pre-context-line"><code>
3526
</code></li>
3527