roda 3.53.0 → 3.54.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 90bdf6d366ffc4bff40aa51721176291fadb80f56d7904965fe46a1385fe4172
4
- data.tar.gz: ab1bea5320b4049e918ebb23d1b081c26d5401000f11b02c5f85a1e1b30899c3
3
+ metadata.gz: '083b83c9271643842b60c7027b16a3ed2068fef54423b3a80dae73ffa991b0cf'
4
+ data.tar.gz: c2b9efd6155dd597f13e7167ce6ad6044f8692fb5dafa7994c1527c3a94f1641
5
5
  SHA512:
6
- metadata.gz: 13bc3beb138174dc8cadfc309458bd1821cbe8b6f80f1cb704752979bf085710181d5fd9df71a3cc1fba2be3b258721f36c8758e202961f9389f23b7555ee78b
7
- data.tar.gz: 7129008315908bf7ebd6c0115cd8eb531a6357617a5f9ce3a0ffae3703a5cd68793af0d43ac4703752e280a5cc6090234b60640fe25384c4fa8aabe8e04b94af
6
+ metadata.gz: e33b2bc1b476bb103d380ac0b310e09640a0bdbce160c7307c92fba93b2dbb2f2a149b2ea3e1db65701354ab274d4d5cea03a7d813f9c81b271bb43d31915503
7
+ data.tar.gz: 9c3f7d67ed534f769ba453974b2dca02318a3330064d5f350ed6f8e0d25314513d884cddbaa6a0e0b9fae36b962fec659db050ced37e543201d4271099813eda
data/CHANGELOG CHANGED
@@ -1,3 +1,21 @@
1
+ = 3.54.0 (2022-03-14)
2
+
3
+ * Make chunked plugin not use Transfer-Encoding: chunked by default (jeremyevans)
4
+
5
+ * Make run_handler plugin close bodies for upstream 404 responses when using not_found: :pass (jeremyevans)
6
+
7
+ * Drop all 1xx bodies in the drop body plugin (jeremyevans)
8
+
9
+ * Do not set a Content-Length header for 205 responses on Rack <2.0.2 (jeremyevans)
10
+
11
+ * Use Rack::Files instead of Rack::File if available, to avoid deprecation warnings (jeremyevans)
12
+
13
+ * Work with Rack 3 SPEC, using Rack::Headers to handle lowercasing header keys on Rack 3 (jeremyevans)
14
+
15
+ * Allow overriding script tag type attribute returned by assets method in assets plugin (pusewicz) (#250)
16
+
17
+ * Make reloading render plugin after additional_view_directories plugin retain :allowed_paths (jeremyevans)
18
+
1
19
  = 3.53.0 (2022-02-14)
2
20
 
3
21
  * Make indifferent_params plugin support rack main branch (jeremyevans)
@@ -480,592 +498,6 @@
480
498
 
481
499
  * Remove deprecated constants and plugins (jeremyevans)
482
500
 
483
- = 2.29.0 (2017-08-16)
484
-
485
- * Deprecate accessing multi_route namespace when there are no routes (jeremyevans)
486
-
487
- * Deprecate additional internal constants (jeremyevans)
488
-
489
- * Respect :root app option when using :layout_opts=>:views render plugin option (jeremyevans)
490
-
491
- * Deprecate rendering templates outside of render plugin :allowed_paths option by default (jeremyevans)
492
-
493
- * Deprecate :cache=>nil/false render plugin option overriding :cache render/view method option (jeremyevans)
494
-
495
- * Deprecate using :header matcher in header_matchers plugin without :header_matcher_prefix app option (jeremyevans)
496
-
497
- * Deprecate using content_for multiple times with the same key in the content_for plugin unless :append plugin option is used (jeremyevans)
498
-
499
- * Deprecate use of :host matcher with regexp value in header_matchers plugin without :host_matcher_captures app option (jeremyevans)
500
-
501
- * Deprecate view_options plugin locals handling, move to the new branch_locals plugin (jeremyevans)
502
-
503
- * Deprecate render plugin locals handling, move to the new render_locals plugin (jeremyevans)
504
-
505
- * Deprecate the :ext render method and plugin option (jeremyevans)
506
-
507
- * Deprecate the view_subdirs plugin alias for the view_options plugin (jeremyevans)
508
-
509
- * Deprecate Stream#callback in the streaming plugin (jeremyevans)
510
-
511
- * Deprecate the automatic support for EventMachine in the streaming plugin (jeremyevans)
512
-
513
- * Deprecate static_path_info plugin, which has been a no-op in Roda 2 (jeremyevans)
514
-
515
- * Deprecate render plugin :escape option loading Erubis escaping support (jeremyevans)
516
-
517
- * Deprecate the per_thread_caching plugin (jeremyevans)
518
-
519
- * Deprecate the websockets plugin (jeremyevans)
520
-
521
- * Deprecate treating unsupported matchers as always matching (jeremyevans)
522
-
523
- * Deprecate ignoring unsupported match block return values (jeremyevans)
524
-
525
- * Deprecate the :format, :opt, and :optd default symbol matchers in the symbol_matchers plugin (jeremyevans)
526
-
527
- * Deprecate use of placeholders in string matchers by default, add placeholder_string_matchers plugin for it (jeremyevans)
528
-
529
- = 2.28.0 (2017-07-14)
530
-
531
- * Deprecate unneeded internal constants (jeremyevans)
532
-
533
- * Optimize for ruby 2.3+ using frozen string literals instead of constants (jeremyevans)
534
-
535
- * Move 303 default redirect status from sinatra_helpers to status_303 plugin, so it can be loaded separately (plujon) (#122)
536
-
537
- = 2.27.0 (2017-06-14)
538
-
539
- * Add class_matchers plugin for matching other classes (in addition to String/Integer), with user specified regexps and type conversion (jeremyevans)
540
-
541
- * Support String class matcher for non-empty segments, same behavior as symbol matchers but more intuitive and DRY (jeremyevans)
542
-
543
- * Support Integer class matcher for \d+ segments, yielding matched values as integers (jeremyevans)
544
-
545
- = 2.26.0 (2017-05-16)
546
-
547
- * Support :skip_middleware option to csrf plugin to add only the methods and not add the middleware (luciusgone) (#118)
548
-
549
- * Handle multiple types with matching suffixes in the type_routing plugin (e.g. tar.gz and gz) (tomdalling) (#117)
550
-
551
- = 2.25.0 (2017-04-18)
552
-
553
- * Add error_mail plugin, similar to error_email but using mail instead of net/smtp directly (jeremyevans)
554
-
555
- = 2.24.0 (2017-03-15)
556
-
557
- * Have h plugin use cgi/escape if available for faster escaping (jeremyevans)
558
-
559
- * Add disallow_file_uploads plugin for raising an exception if a multipart file upload is attempted (jeremyevans)
560
-
561
- * Add strip_path_prefix plugin for stripping prefixes off of internal absolute paths, making them relative paths (jeremyevans)
562
-
563
- * Add Roda.expand_path method to DRY up path expansion (jeremyevans)
564
-
565
- * Support :freeze_middleware option, which freezes all middleware instances when building the rack app (jeremyevans)
566
-
567
- * Allow middleware plugin to accept a block that will be used to configure the application when used as middleware (jeremyevans)
568
-
569
- * Support an options hash when loading the cookies plugin, that will be used as the defaults for setting and deleting cookies (mwpastore, jeremyevans) (#112)
570
-
571
- * Make the static_routing plugin work with the hooks plugin if the hooks plugin is loaded first (jeremyevans) (#110)
572
-
573
- * Do not modify the render plugin's cache if loading the plugin multiple times (jeremyevans)
574
-
575
- = 2.23.0 (2017-02-24)
576
-
577
- * Add :inherit_cache render plugin option, to create a copy of the cache for subclasses, instead of using an empty cache (jeremyevans)
578
-
579
- * In development mode, default to :explicit_cache=>true, :cache=>true instead of :cache=>false (jeremyevans)
580
-
581
- * Add :explicit_cache render plugin option, to only cache templates if the :cache option is given to render/view (jeremyevans)
582
-
583
- * Add error_email_content method to error_email plugin (jeremyevans)
584
-
585
- * Make error_email method in error_email plugin support non-exception arguments (jeremyevans)
586
-
587
- * Make Roda.freeze in the static_routing plugin return self (jeremyevans)
588
-
589
- = 2.22.0 (2017-01-20)
590
-
591
- * Add support for :verbatim_string_matcher option, for making all string matchers match verbatim (jeremyevans)
592
-
593
- * Add support for :unsupported_matcher => :raise option, for raising on unsupported matcher values (jeremyevans)
594
-
595
- * Add support for :unsupported_block_result => :raise option, for raising on unsupported route/match block return values (jeremyevans)
596
-
597
- = 2.21.0 (2016-12-16)
598
-
599
- * Add handle_stream_error method to streaming plugin, for handling errors when using stream(:loop=>true) (jeremyevans)
600
-
601
- = 2.20.0 (2016-11-13)
602
-
603
- * Support :escape=>:erubi option in the render plugin to use the erubi template engine (jeremyevans)
604
-
605
- = 2.19.0 (2016-10-14)
606
-
607
- * Don't add Content-Type/Content-Length headers for 1xx, 204, 205, 304 statuses (celsworth, jeremyevans) (#101, #102)
608
-
609
- * Optimize indifferent_params plugin when using Rack 2 (jeremyevans)
610
-
611
- * Fix assets_paths method in assets plugin when subresource integrity is used (jeremyevans, celsworth)
612
-
613
- * Make assets plugin depend on h plugin, instead of using Rack::Utils.escape_html (jeremyevans)
614
-
615
- * Make h plugin not escape / (celsworth, jeremyevans) (#100)
616
-
617
- = 2.18.0 (2016-09-13)
618
-
619
- * Add assets_preloading plugin, for creating link tags or Link header for preloading assets (celsworth, jeremyevans) (#98)
620
-
621
- * Add assets_paths method to assets plugin, for just the paths to the assets, instead of the full tags (celsworth) (#96)
622
-
623
- * Make type_routing plugin work correctly with public plugin (celsworth, jeremyevans) (#95)
624
-
625
- * Add static_routing plugin for 3-4x increase in performance for large numbers of static routes (jeremyevans)
626
-
627
- * Make head plugin work with not_allowed plugin if loaded after (jeremyevans) (#92)
628
-
629
- = 2.17.0 (2016-08-13)
630
-
631
- * Add :postprocessor option to assets plugin, for postprocessing assets (e.g. autoprefixing CSS) (celsworth) (#86)
632
-
633
- * Fix path passed to rack apps when using r.run and the type_routing plugin (jeremyevans) (#82)
634
-
635
- * Support :classes option to error_handler plugin for overriding which exception classes to rescue (jeremyevans)
636
-
637
- * Support :layout_opts=>:merge_locals option in render plugin for merging view template locals into layout template locals (jeremyevans) (#80)
638
-
639
- * Support :sri option to assets plugin to enable subresource integrity (jeremyevans)
640
-
641
- * Add run_append_slash plugin, so r.run uses "/" instead of "" for app's PATH_INFO (kenaniah) (#77)
642
-
643
- = 2.16.0 (2016-07-13)
644
-
645
- * Add type_routing plugin, for routing based on path extensions and Accept headers (Papierkorb, jeremyevans) (#75)
646
-
647
- * Add unescape_path plugin, for decoding URL-encoded PATH_INFO before routing (jeremyevans) (#74)
648
-
649
- * Add request_headers plugin, for simpler access to request headers (celsworth) (#72)
650
-
651
- = 2.15.0 (2016-06-13)
652
-
653
- * Add public plugin for r.public method for serving all files in the public directory (jeremyevans)
654
-
655
- * Make send_file in sinatra_helpers plugin work with Rack 2 (jeremyevans)
656
-
657
- * Make :header matcher prefixes the env key with HTTP_ if application :header_matcher_prefix option is set (timothypage, jeremyevans) (#69)
658
-
659
- * Add content_for plugin :append option to support appending to the existing content (evanleck, jeremyevans) (#66)
660
-
661
- = 2.14.0 (2016-05-13)
662
-
663
- * Add symbol_status plugin for using symbols as status codes (Papierkorb) (#65)
664
-
665
- * Make middleware plugin also run the application's middleware (jeremyevans)
666
-
667
- = 2.13.0 (2016-04-14)
668
-
669
- * Add :check_paths and :allowed_paths to render plugin options to avoid security issues with template rendering (jeremyevans)
670
-
671
- = 2.12.0 (2016-03-15)
672
-
673
- * Allow error handler access to the request's remaining_path (jeremyevans)
674
-
675
- * Add optimized_string_matchers plugin, containing optimized matchers for single string arguments (jeremyevans)
676
-
677
- * Optimize string matching code for strings without placeholders for up to a 60% performance increase (jeremyevans)
678
-
679
- * Optimize symbol matching code for up to a 60% performance increase (jeremyevans)
680
-
681
- = 2.11.0 (2016-02-16)
682
-
683
- * Support :scope option in render plugin, for specifying object in which to evaluate the template (jeremyevans)
684
-
685
- * Make minjs compressor support in assets plugin support latest version of Minjs (jeremyevans)
686
-
687
- * Add params_capturing plugin, for storing matcher captures in the request params (jeremyevans)
688
-
689
- = 2.10.0 (2016-01-15)
690
-
691
- * Do not override existing Content-Type header in json plugin (jeremyevans)
692
-
693
- * Add :content_type option to json plugin to override Content-Type header used (Kyrremann) (#58)
694
-
695
- * Add support for running with --enable-frozen-string-literal on ruby 2.3 (jeremyevans)
696
-
697
- * Add Streaming::Stream#write method so that IO.copy_stream will work (janko-m) (#56)
698
-
699
- = 2.9.0 (2015-12-15)
700
-
701
- * Support passing the content as a string argument instead of a block in the content_for plugin (badosu) (#52)
702
-
703
- = 2.8.0 (2015-11-16)
704
-
705
- * Add multi_view plugin for easily setting up routing for rendering multiple views (jeremyevans)
706
-
707
- * Make content_for plugin work with haml and potentially other non-erb template engines (plukevdh) (#50)
708
-
709
- = 2.7.0 (2015-10-13)
710
-
711
- * Add run_handler plugin for modifying rack response arrays when using r.run, and continuing routing for 404 responses (jeremyevans)
712
-
713
- * Add response_request plugin allowing response object access to request object (jeremyevans)
714
-
715
- * Add default_status plugin for overriding the default response status (celsworth) (#47)
716
-
717
- * Make RodaCache synchronize access on MRI (jeremyevans)
718
-
719
- * Support opts[:host_matcher_captures] = true to make :host=>/regexp/ matcher yield captures in the header_matchers plugin (jeremyevans)
720
-
721
- * Allow Roda.rewrite_path to take a block in the path_rewriter plugin (Freaky) (#45)
722
-
723
- = 2.6.0 (2015-09-14)
724
-
725
- * Add :params and :params! matchers to param_matchers plugin (jeremyevans)
726
-
727
- * Merge options when loading csrf plugin multiple times (jeremyevans)
728
-
729
- * Allow request.halt to work in before hooks in the hooks plugin (celsworth) (#38)
730
-
731
- = 2.5.1 (2015-08-13)
732
-
733
- * Allow multi_route and middleware plugins to work together (janko-m) (#36)
734
-
735
- = 2.5.0 (2015-07-14)
736
-
737
- * Make :by_name option to path plugin default to true in development (jeremyevans)
738
-
739
- * Add :cache_class option to render plugin, for customized template cache behavior (celsworth) (#34)
740
-
741
- * Add :compiled_asset_host option to assets plugin, to use a host for compiled assets (jeremyevans)
742
-
743
- * Allow r.multi_run to take a block that is called with the prefix before dispatching to the rack app (mikz) (#32)
744
-
745
- = 2.4.0 (2015-06-15)
746
-
747
- * Add websockets plugin, for integration with faye-websocket (jeremyevans)
748
-
749
- * Add status_handler plugin, similar to not_found but for any status code (celsworth) (#29)
750
-
751
- * Support Closure Compiler, Uglifier, and MinJS for compressing javascript in the assets plugin (jeremyevans)
752
-
753
- * Make Roda.plugin always return nil (jeremyevans)
754
-
755
- * Add :gzip option to assets plugin (jeremyevans)
756
-
757
- = 2.3.0 (2015-05-13)
758
-
759
- * Make assets plugin work better with json plugin when r.assets is the last method called in a route block (jeremyevans) (#27)
760
-
761
- * Support no_mail! method in the mailer plugin, for skipping an email (jeremyevans)
762
-
763
- * Add precompile_templates plugin, for saving memory when using a forking webserver (jeremyevans)
764
-
765
- * Document how to allow per-branch HTML escaping of <%= %> in the view_options plugin (jeremyevans)
766
-
767
- * Add :include_request option to json and json_parser plugins to include request in :serializer/:parser call (janko-m) (#26)
768
-
769
- * Optimize template cache lookup in render plugin when :cache_key is given (jeremyevans)
770
-
771
- * Add :engine_opts option to render plugin, for specifying per-template engine options (jeremyevans)
772
-
773
- * The render plugin and render/view :ext option is now replaced by the :engine option (jeremyevans)
774
-
775
- * Add path_rewriter plugin, for rewriting paths before routing (jeremyevans)
776
-
777
- * Add :cache_key option to render/view to explicitly set the template cache key (jeremyevans)
778
-
779
- * Don't cache templates if :template_block is given to render/view, unless :cache=>true is used (jeremyevans)
780
-
781
- * Add :cache option to render/view to force caching or not caching the template (jeremyevans)
782
-
783
- * Avoid rehashing hashes at runtime in plugins (jeremyevans)
784
-
785
- * Add heartbeat plugin for heartbeat support (jeremyevans)
786
-
787
- * Support :serializer option in json plugin (janko-m) (#21)
788
-
789
- * Add json_parser plugin, for parsing request bodies in JSON format (jeremyevans)
790
-
791
- = 2.2.0 (2015-04-13)
792
-
793
- * Add :escaper render plugin option to support custom escaping of <%= %> tags when :escape is used (jeremyevans)
794
-
795
- * Add :escape_safe_classes render plugin option, to not escape certain string subclasses when :escape is used (jeremyevans)
796
-
797
- * Split partials method from padrino_render plugin into partials plugin (kematzy) (#19)
798
-
799
- * Add shared_vars plugin, for sharing variables between multiple Roda apps (jeremyevans)
800
-
801
- * Add delay method to chunked plugin, for delaying a block execution until right before content template rendering (jeremyevans)
802
-
803
- * Have default Content-Type header when using the default_headers plugin (jeremyevans)
804
-
805
- * Add :by_name option to the path plugin, for registering classes by name, useful when reloading code (jeremyevans)
806
-
807
- * Add Roda.path_block to get the block related to the given class used for Road#path (jeremyevans)
808
-
809
- * Make Roda#path work correctly in subclasses (jeremyevans)
810
-
811
- = 2.1.0 (2015-03-13)
812
-
813
- * Have add_file in the mailer plugin support blocks, which are called after the file has been added (jeremyevans)
814
-
815
- * Add append_view_subdir to view_options, for appending to an existing view subdirectory (jeremyevans)
816
-
817
- * Rename view_subdirs plugin to view_options, add support for branch/route specific view/layout options/locals (jeremyevans)
818
-
819
- * Merge :locals set in the render plugin options into :locals provided in call to view/render (jeremyevans)
820
-
821
- * Add support for registering classes in the path plugin for use with Roda#path (jeremyevans)
822
-
823
- * Use :add_script_name app option as default for path method :add_script_name option in path plugin (jeremyevans)
824
-
825
- * Support :add_script_name app option in assets plugin, to prefix URLs with SCRIPT_NAME (jeremyevans)
826
-
827
- * Make r.multi_route in multi_route plugin work without any named routes defined (jeremyevans)
828
-
829
- * Add :static plugin, for more easily serving static files (jeremyevans)
830
-
831
- * Recognize Roda :root option in render and assets plugins (jeremyevans)
832
-
833
- * Make :layout=>false option in render plugin override previous layout template (jeremyevans)
834
-
835
- * Make add_file in the mailer plugin add the files after the email body instead of before (jeremyevans)
836
-
837
- = 2.0.0 (2015-02-13)
838
-
839
- * Allow Roda app to be used as a regular rack app even when using the middleware plugin (jeremyevans)
840
-
841
- * Make render plugin :layout option always be true or false (jeremyevans)
842
-
843
- * Make :layout=>true view option use the default layout (jeremyevans)
844
-
845
- * Make error_handler plugin rescue ScriptError in addition to StandardError (jeremyevans)
846
-
847
- * Make halt plugin integrate with symbol_views, json, and similar plugins (jeremyevans)
848
-
849
- * Add padrino_render plugin, adding render/partial methods that work similar to Padrino (jeremyevans)
850
-
851
- * Add Roda#render_template private method for template rendering, for use by plugins (jeremyevans)
852
-
853
- * Make Roda#initialize take env hash, #call take route_block, remove private #_route (jeremyevans)
854
-
855
- * Remove keep_remaining_path/update_remaining_path private request methods (jeremyevans)
856
-
857
- * Don't modify SCRIPT_NAME/PATH_INFO during routing, merging static_path_info plugin into core (jeremyevans)
858
-
859
- * Remove code deprecated in Roda 1.3.0 (jeremyevans)
860
-
861
- = 1.3.0 (2015-01-13)
862
-
863
- * Make static_path_info plugin restore original SCRIPT_NAME/PATH_INFO before returning from r.run (jeremyevans)
864
-
865
- * Add RodaMajorVersion, RodaMinorVersion, and RodaPatchVersion (jeremyevans)
866
-
867
- * Add delete_empty_headers plugin for deleting response headers that are empty before return response (jeremyevans)
868
-
869
- * Make freeze class method freeze internal data structures to avoid thread safety issues (jeremyevans)
870
-
871
- * Deprecate mutating plugin option hashes for chunked, default_headers, error_email, json, and render plugins (jeremyevans)
872
-
873
- * Fix subclassing app and using r.multi_run in subclass in multi_run plugin (jeremyevans)
874
-
875
- * Support :classes option in json plugin to set the classes to use (jeremyevans)
876
-
877
- * Improve performance in default_headers plugin by not duping the headers (jeremyevans)
878
-
879
- * Use :template_opts instead of :opts for providing options to the template in the render plugin (jeremyevans)
880
-
881
- * Support :match_header_yield Roda option in the header_matchers plugin, causing the :header match to yield the value (jeremyevans)
882
-
883
- * Move :param and :param! hash matchers to the param_matchers plugin (jeremyevans)
884
-
885
- * Add path_matchers plugin, for :extension, :prefix, and :suffix hash matchers (jeremyevans)
886
-
887
- * Move Roda.hash_matcher to hash_matcher plugin (jeremyevans)
888
-
889
- * Move Roda.request_module and .response_module to module_include plugin (jeremyevans)
890
-
891
- * Move RodaResponse#set_cookie and #delete_cookie to cookies plugin (jeremyevans)
892
-
893
- * Deprecate RodaRequest#full_path_info, use #path instead (jeremyevans)
894
-
895
- * Add class_delegate to the delegate plugin (jeremyevans)
896
-
897
- * Make not_found plugin clear headers for response if it is not found (jeremyevans)
898
-
899
- * Make error_handler plugin use a new response instead of reusing existing response (jeremyevans)
900
-
901
- * Make RodaResponse a subclass of Object instead of Rack::Response (jeremyevans)
902
-
903
- = 1.2.0 (2014-12-17)
904
-
905
- * Don't override explicit nil :default_encoding template option in the render plugin (jeremyevans)
906
-
907
- * Add remaining_path and matched_path request methods (jeremyevans)
908
-
909
- * Add slash_path_emty plugin, for considering a path of "/" as empty when doing a terminal match (jeremyevans)
910
-
911
- * Remove def_verb_method request class method (jeremyevans)
912
-
913
- * Support :add_script_name, :name, :url, and :url_only options when creating named paths in the path plugin (jeremyevans)
914
-
915
- * Add match_affix plugin, for overriding default prefix/suffix used in match patterns (jeremyevans)
916
-
917
- * Add empty_root plugin, for making root matcher also match empty string (jeremyevans)
918
-
919
- * Add roda_class instance methods to RodaRequest and RodaResponse, to DRY up plugin code (jeremyevans)
920
-
921
- * Add sinatra_helpers plugin, porting Sinatra::Helpers methods not covered by other plugins (jeremyevans)
922
-
923
- * Don't set the default headers until the response is finished (jeremyevans)
924
-
925
- * Add RodaRequest#default_redirect_status, so plugins can override the default status used for redirects (jeremyevans)
926
-
927
- * Add drop_body plugin, for automatically dropping body and Content-{Length,Type} headers based on response status (jeremyevans)
928
-
929
- * Add clear_middleware! class method, for clearing the current middleware (jeremyevans)
930
-
931
- * Add inherit_middleware class accessor, allowing users to turn off middleware inheritance (jeremyevans)
932
-
933
- * Add multi_run plugin, for dispatching to multiple rack applications based on the request path prefix (jeremyevans)
934
-
935
- * Add environments plugin, for handling development/test/production environments (jeremyevans)
936
-
937
- * Do not cache templates by default if RACK_ENV is development (jeremyevans)
938
-
939
- * Add delay_build plugin, to delay building the rack app until Roda.app is called (jeremyevans)
940
-
941
- * Add :user_agent hash matcher to the header_matchers plugin (jeremyevans)
942
-
943
- * Fix caching of templates in the render plugin when :opts or :template_class is used (jeremyevans)
944
-
945
- * Require loading the render plugin again if you want to change the default layout (jeremyevans)
946
-
947
- * Pass :css_opts and :js_opts as template options (via :opts) instead of render options when rendering (jeremyevans)
948
-
949
- * Only pass :opts hash to template class during rendering, instead of all render/view options (jeremyevans)
950
-
951
- * Support :template_class option in the render plugin for overriding template class to use (jeremyevans)
952
-
953
- * Automatically dup unfrozen Array/Hash opts values when subclassing (jeremyevans)
954
-
955
- * Add named_templates plugin, for creating inline templates by name, instead of storing them in the file system (jeremyevans)
956
-
957
- * Support :template option in for render/view to specify template to use, instead of requiring separate argument (jeremyevans)
958
-
959
- * Add class_level_routing plugin, for a DSL similar to Sinatra (jeremyevans)
960
-
961
- * Make RodaRequest.consume_pattern not capture pattern by default (jeremyevans)
962
-
963
- * Add static_path_info plugin, making Roda not modify PATH_INFO or SCRIPT_NAME during routing (jeremyevans)
964
-
965
- * Use local/instance variable lookups instead of method calls to improve performance (jeremyevans)
966
-
967
- * Add RodaRequest#session, and have #session delegate to that (jeremyevans)
968
-
969
- * Add delegate plugin, for easily creating methods that delegate to request or response (jeremyevans)
970
-
971
- * Add mailer plugin, allowing use of a routing tree for email instead of web responses (jeremyevans)
972
-
973
- = 1.1.0 (2014-11-11)
974
-
975
- * Add assets plugin, for rendering assets on the fly, or compiling them to a single compressed file (cj, jeremyevans) (#5)
976
-
977
- * Make InstanceMethods in plugins not include constants, as they would pollute the constant namespace (jeremyevans)
978
-
979
- * Make response.finish add the Content-Length header, not response.write (jeremyevans)
980
-
981
- * Add response.finish_with_body to override response body used (jeremyevans)
982
-
983
- * Use allocate instead of new in rack app (jeremyevans)
984
-
985
- * Add chunked plugin, for easy streaming of template responses using Transfer-Encoding: chunked (jeremyevans)
986
-
987
- * Add namespace support to the multi_route plugin, to support more complex applications (jeremyevans)
988
-
989
- * Make r.multi_route use named route return value if not passed a block (jeremyevans)
990
-
991
- * Make r.multi_route prefer longer route if multiple routes have the same prefix (jeremyevans)
992
-
993
- * Add caching plugin, for handling http caching (jeremyevans)
994
-
995
- * Support adding middleware after the route block has been added (jeremyevans)
996
-
997
- * Allow Roda subclasses to use route block from superclass (jeremyevans)
998
-
999
- * Have r.multi_route ignore non-String named routes (jeremyevans)
1000
-
1001
- * Pick up newly added named routes while running in the multi_route plugin, useful for development (jeremyevans)
1002
-
1003
- * Add path plugin, for named path support (jeremyevans) (#4)
1004
-
1005
- * Add error_email plugin, for easily emailing an error notification for an exception (jeremyevans)
1006
-
1007
- = 1.0.0 (2014-08-19)
1008
-
1009
- * Don't have :extension hash matcher force a terminal match (jeremyevans)
1010
-
1011
- * Add :content option to view method in render plugin to use given content instead of rendering a template (jeremyevans)
1012
-
1013
- * Add :escape option to render plugin for using erb templates where <%= %> escapes and <%== %> does not (jeremyevans)
1014
-
1015
- * Make multi_route plugin route("route_name") method a request method instead of an instance method (jeremyevans)
1016
-
1017
- * Add r.multi_route method to multi_route plugin, for dispatching to named route based on first segment in path (jeremyevans)
1018
-
1019
- * Allow non-GET requests to use r.redirect with no argument, redirecting to current path (jeremyevans)
1020
-
1021
- * Add head plugin, for handling HEAD requests like GET requests with an empty body (jeremyevans)
1022
-
1023
- * Optimize consuming patterns by using a positive lookahead assertion (jeremyevans)
1024
-
1025
- * Add not_allowed plugin, for automatically returning 405 Method Not Allowed responses (jeremyevans)
1026
-
1027
- * Optimize match blocks with no arguments (jeremyevans)
1028
-
1029
- * Add content_for plugin, for storing content in one template and retrieving it in another (jeremyevans)
1030
-
1031
- * Add render_each plugin, for rendering a template for each value in an enumerable (jeremyevans)
1032
-
1033
- * Add backtracking_array plugin, allowing array matchers to backtrack if later matchers do not match (jeremyevans)
1034
-
1035
- * Add :all hash matcher, allowing array matchers to include conditions where you want to match multiple conditions (jeremyevans)
1036
-
1037
- * Add json plugin, allowing match blocks to return arrays/hashes, returning JSON (jeremyevans)
1038
-
1039
- * Add view_subdirs plugin, for setting a subdirectory for views on a per-request basis (jeremyevans)
1040
-
1041
- * Allow default halt method to take no arguments, and use the current response (jeremyevans)
1042
-
1043
- * Add symbol_views plugin, allowing match blocks to return a template name symbol (jeremyevans)
1044
-
1045
- * Add per_thread_caching plugin, for using separate caches per thread instead of shared thread-safe caches (jeremyevans)
1046
-
1047
- * Add hash_matcher class method, for easily creating hash match methods (jeremyevans)
1048
-
1049
- * Add symbol_matchers plugin, for using symbol-specific matching regexps (jeremyevans)
1050
-
1051
- * Add csrf plugin for csrf protection using rack_csrf (jeremyevans)
1052
-
1053
- * Optimize r.is, r.get, r.post and similar methods by reducing the number of Array objects created (jeremyevans)
1054
-
1055
- * Support RequestClassMethods and ResponseClassMethods in plugins (jeremyevans)
1056
-
1057
- * Add Roda::RodaCache for a thread safe cache, currently used for match patterns, templates, and plugins (jeremyevans)
1058
-
1059
- * Optimize matching by caching consume regexp for strings, regexp, symbol, and :extension matchers (jeremyevans)
1060
-
1061
- * Add r.root for GET / requests, for easier to read version of r.get "" (jeremyevans)
1062
-
1063
- * Optimize r.is terminal matcher, remove :term hash matcher (jeremyevans)
1064
-
1065
- * Make flash plugin no longer depend on sinatra-flash (jeremyevans)
1066
-
1067
- * Move version file to roda/version so it can be required separately without loading dependencies (jeremyevans)
1068
-
1069
- = 0.9.0 (2014-07-30)
501
+ === Older
1070
502
 
1071
- * Initial public release
503
+ See doc/CHANGELOG.old
@@ -0,0 +1,48 @@
1
+ = New Features
2
+
3
+ * You can now override the type attribute for script tags produced
4
+ by the assets plugin, by providing a :type attribute when calling
5
+ the assets method.
6
+
7
+ = Other Improvements
8
+
9
+ * Reloading the render plugin after the additional_view_directories
10
+ plugin no longer removes the additional view directories from
11
+ the allowed paths for templates.
12
+
13
+ * When using Rack 3, Roda will now use an instance of Rack::Headers
14
+ instead of a plain hash for the headers, allowing for compliance
15
+ with the Rack 3 SPEC (which will require lowercase header keys).
16
+
17
+ * The public, multi_public, and sinatra_helpers plugin now use
18
+ Rack::Files instead of Rack::File if available, as Rack::File will
19
+ be deprecated in Rack 3.0.
20
+
21
+ * The json_parser plugin no longer rewinds the request body before
22
+ and after reading it when used with Rack 3.0, as Rack 3.0 has
23
+ dropped the requirement for rewindable input.
24
+
25
+ * The run_handler plugin now closes bodies for upstream 404 responses
26
+ when using the not_found: :pass option.
27
+
28
+ * The chunked plugin no longer uses Transfer-Encoding: chunked by
29
+ default. Requiring the use of Transfer-Encoding: chunked made the
30
+ plugin only work on HTTP 1.1, and not older or newer versions. The
31
+ plugin still allows for streaming template bodies as they are being
32
+ rendered. To get the previous behavior of forcing the use of
33
+ Transfer-Encoding: chunked, you can use the :force_chunked_encoding
34
+ plugin option
35
+
36
+ * Roda now supports testing with Rack::Lint. This found multiple
37
+ violations of the Rack SPEC which are fixed in this version, and
38
+ should ensure that Roda stays in compliance with the Rack SPEC going
39
+ forward.
40
+
41
+ = Backwards Compatibility
42
+
43
+ * Roda will no longer set the Content-Length header for 205 responses
44
+ when using Rack <2.0.2, as doing so violates the Rack SPEC for those
45
+ Rack versions.
46
+
47
+ * The drop_body plugin now drops response bodies for all 1xx responses,
48
+ not just for 100 and 101 responses, in compliance with the Rack SPEC.
@@ -36,9 +36,7 @@ class Roda
36
36
  # is also added as an allowed path.
37
37
  def self.configure(app, view_dirs)
38
38
  view_dirs = app.opts[:additional_view_directories] = view_dirs.map{|f| app.expand_path(f, nil)}.freeze
39
- opts = app.opts[:render]
40
- app.opts[:render] = opts.merge(:allowed_paths=>(opts[:allowed_paths] + view_dirs).uniq.freeze)
41
- opts.freeze
39
+ app.plugin :render, :allowed_paths=>(app.opts[:render][:allowed_paths] + view_dirs).uniq.freeze
42
40
  end
43
41
 
44
42
  module InstanceMethods
@@ -708,6 +708,9 @@ class Roda
708
708
  # To return the tags for a specific asset group, use an array for
709
709
  # the type, such as [:css, :frontend].
710
710
  #
711
+ # You can specify custom attributes for the tag by passing a hash
712
+ # as the attrs argument.
713
+ #
711
714
  # When the assets are not compiled, this will result in a separate
712
715
  # tag for each asset file. When the assets are compiled, this will
713
716
  # result in a single tag to the compiled asset file.
@@ -720,13 +723,13 @@ class Roda
720
723
  attrs[:integrity] = "#{algo}-#{h([[hash].pack('H*')].pack('m').tr("\n", ''))}"
721
724
  end
722
725
 
723
- attrs = attrs.map{|k,v| "#{k}=\"#{h(v)}\""}.join(' ')
726
+ attributes = attrs.map{|k,v| "#{k}=\"#{h(v)}\""}.join(' ')
724
727
 
725
728
  if ltype == :js
726
- tag_start = "<script type=\"text/javascript\" #{attrs} src=\""
729
+ tag_start = "<script#{' type="text/javascript"' unless attrs[:type]} #{attributes} src=\""
727
730
  tag_end = "\"></script>"
728
731
  else
729
- tag_start = "<link rel=\"stylesheet\" #{attrs} href=\""
732
+ tag_start = "<link rel=\"stylesheet\" #{attributes} href=\""
730
733
  tag_end = "\" />"
731
734
  end
732
735
 
@@ -3,11 +3,11 @@
3
3
  #
4
4
  class Roda
5
5
  module RodaPlugins
6
- # The chunked plugin allows you to stream responses to clients using
7
- # Transfer-Encoding: chunked. This can significantly improve performance
8
- # of page rendering on the client, as it flushes the headers and top part
9
- # of the layout template (generally containing references to the stylesheet
10
- # and javascript assets) before rendering the content template.
6
+ # The chunked plugin allows you to stream rendered views to clients.
7
+ # This can significantly improve performance of page rendering on the
8
+ # client, as it flushes the headers and top part of the layout template
9
+ # (generally containing references to the stylesheet and javascript assets)
10
+ # before rendering the content template.
11
11
  #
12
12
  # This allows the client to fetch the assets while the template is still
13
13
  # being rendered. Additionally, this plugin makes it easy to defer
@@ -17,11 +17,11 @@ class Roda
17
17
  # order to render the content template, such as retrieving values from a
18
18
  # database.
19
19
  #
20
- # There are a couple disadvantages of streaming using chunked encoding.
21
- # First is that the layout must be rendered before the content, so any state
22
- # changes made in your content template will not affect the layout template.
23
- # Second, error handling is reduced, since if an error occurs while
24
- # rendering a template, a successful response code has already been sent.
20
+ # There are a couple disadvantages of streaming. First is that the layout
21
+ # must be rendered before the content, so any state changes made in your
22
+ # content template will not affect the layout template. Second, error
23
+ # handling is reduced, since if an error occurs while rendering a template,
24
+ # a successful response code has already been sent.
25
25
  #
26
26
  # To use chunked encoding for a response, just call the chunked method
27
27
  # instead of view:
@@ -56,7 +56,6 @@ class Roda
56
56
  # end
57
57
  # end
58
58
  #
59
- #
60
59
  # If you want to chunk all responses, pass the :chunk_by_default option
61
60
  # when loading the plugin:
62
61
  #
@@ -121,12 +120,7 @@ class Roda
121
120
  # flush to output the message to the client inside handle_chunk_error.
122
121
  #
123
122
  # In order for chunking to work, you must make sure that no proxies between
124
- # the application and the client buffer responses. Also, this
125
- # plugin only works for HTTP/1.1 requests since Transfer-Encoding: chunked
126
- # is not supported in HTTP/1.0. If an HTTP/1.0 request is submitted, this
127
- # plugin will automatically fallback to the normal template rendering.
128
- # Note that some proxies including nginx default to HTTP/1.0 even if the
129
- # client supports HTTP/1.1. For nginx, set the proxy_http_version to 1.1.
123
+ # the application and the client buffer responses.
130
124
  #
131
125
  # If you are using nginx and have it set to buffer proxy responses by
132
126
  # default, you can turn this off on a per response basis using the
@@ -135,6 +129,15 @@ class Roda
135
129
  #
136
130
  # plugin :chunked, headers: {'X-Accel-Buffering'=>'no'}
137
131
  #
132
+ # By default, this plugin does not use Transfer-Encoding: chunked, it only
133
+ # returns a body that will stream the response in chunks. If you would like
134
+ # to force the use of Transfer-Encoding: chunked, you can use the
135
+ # :force_chunked_encoding plugin option. If using the
136
+ # :force_chunked_encoding plugin option, chunking will only be used for
137
+ # HTTP/1.1 requests since Transfer-Encoding: chunked is only supported
138
+ # in HTTP/1.1 (non-HTTP/1.1 requests will have behavior similar to
139
+ # calling no_chunk!).
140
+ #
138
141
  # The chunked plugin requires the render plugin, and only works for
139
142
  # template engines that store their template output variable in
140
143
  # @_out_buf. Also, it only works if the content template is directly
@@ -155,12 +158,14 @@ class Roda
155
158
  # :headers :: Set default additional headers to use when calling view
156
159
  def self.configure(app, opts=OPTS)
157
160
  app.opts[:chunk_by_default] = opts[:chunk_by_default]
161
+ app.opts[:force_chunked_encoding] = opts[:force_chunked_encoding]
158
162
  if opts[:headers]
159
163
  app.opts[:chunk_headers] = (app.opts[:chunk_headers] || {}).merge(opts[:headers]).freeze
160
164
  end
161
165
  end
162
166
 
163
- # Rack response body instance for chunked responses
167
+ # Rack response body instance for chunked responses using
168
+ # Transfer-Encoding: chunked.
164
169
  class Body
165
170
  # Save the scope of the current request handling.
166
171
  def initialize(scope)
@@ -184,6 +189,22 @@ class Roda
184
189
  end
185
190
  end
186
191
 
192
+ # Rack response body instance for chunked responses not
193
+ # using Transfer-Encoding: chunked.
194
+ class StreamBody
195
+ # Save the scope of the current request handling.
196
+ def initialize(scope)
197
+ @scope = scope
198
+ end
199
+
200
+ # Yield each non-empty chunk as the body.
201
+ def each(&block)
202
+ @scope.each_chunk do |chunk|
203
+ yield chunk if chunk && !chunk.empty?
204
+ end
205
+ end
206
+ end
207
+
187
208
  module InstanceMethods
188
209
  # Disable chunking for the current request. Mostly useful when
189
210
  # chunking is turned on by default.
@@ -205,7 +226,7 @@ class Roda
205
226
  # an overview. If a block is given, it is passed to #delay.
206
227
  def chunked(template, opts=OPTS, &block)
207
228
  unless defined?(@_chunked)
208
- @_chunked = env['HTTP_VERSION'] == "HTTP/1.1"
229
+ @_chunked = !self.opts[:force_chunked_encoding] || env['HTTP_VERSION'] == "HTTP/1.1"
209
230
  end
210
231
 
211
232
  if block
@@ -235,9 +256,14 @@ class Roda
235
256
  if chunk_headers = self.opts[:chunk_headers]
236
257
  headers.merge!(chunk_headers)
237
258
  end
238
- headers['Transfer-Encoding'] = 'chunked'
259
+ if self.opts[:force_chunked_encoding]
260
+ headers['Transfer-Encoding'] = 'chunked'
261
+ body = Body.new(self)
262
+ else
263
+ body = StreamBody.new(self)
264
+ end
239
265
 
240
- throw :halt, res.finish_with_body(Body.new(self))
266
+ throw :halt, res.finish_with_body(body)
241
267
  end
242
268
 
243
269
  # Delay the execution of the block until right before the
@@ -15,22 +15,23 @@ class Roda
15
15
  DROP_BODY_STATUSES = [100, 101, 102, 204, 205, 304].freeze
16
16
  RodaPlugins.deprecate_constant(self, :DROP_BODY_STATUSES)
17
17
 
18
+ DROP_BODY_RANGE = 100..199
19
+ private_constant :DROP_BODY_RANGE
20
+
18
21
  # If the response status indicates a body should not be
19
22
  # returned, use an empty body and remove the Content-Length
20
23
  # and Content-Type headers.
21
24
  def finish
22
25
  r = super
23
26
  case r[0]
24
- when 100, 101, 102, 204, 304
27
+ when DROP_BODY_RANGE, 204, 304
25
28
  r[2] = EMPTY_ARRAY
26
29
  h = r[1]
27
30
  h.delete("Content-Length")
28
31
  h.delete("Content-Type")
29
32
  when 205
30
33
  r[2] = EMPTY_ARRAY
31
- h = r[1]
32
- h["Content-Length"] = '0'
33
- h.delete("Content-Type")
34
+ empty_205_headers(r[1])
34
35
  end
35
36
  r
36
37
  end
@@ -14,6 +14,11 @@ class Roda
14
14
  #
15
15
  # plugin :heartbeat, path: '/status'
16
16
  module Heartbeat
17
+ # :nocov:
18
+ HEADER_CLASS = (defined?(Rack::Headers) && Rack::Headers.is_a?(Class)) ? Rack::Headers : Hash
19
+ # :nocov:
20
+ private_constant :HEADER_CLASS
21
+
17
22
  HEARTBEAT_RESPONSE = [200, {'Content-Type'=>'text/plain'}.freeze, ['OK'.freeze].freeze].freeze
18
23
 
19
24
  # Set the heartbeat path to the given path.
@@ -28,7 +33,7 @@ class Roda
28
33
  def _roda_before_20__heartbeat
29
34
  if env['PATH_INFO'] == opts[:heartbeat_path]
30
35
  response = HEARTBEAT_RESPONSE.dup
31
- response[1] = Hash[response[1]]
36
+ response[1] = HEADER_CLASS[response[1]]
32
37
  throw :halt, response
33
38
  end
34
39
  end
@@ -52,9 +52,7 @@ class Roda
52
52
  if post_params = (env["roda.json_params"] || env["rack.request.form_hash"])
53
53
  post_params
54
54
  elsif (input = env["rack.input"]) && content_type =~ /json/
55
- input.rewind
56
- str = input.read
57
- input.rewind
55
+ str = _read_json_input(input)
58
56
  return super if str.empty?
59
57
  begin
60
58
  json_params = parse_json(str)
@@ -81,6 +79,23 @@ class Roda
81
79
  args << self if roda_class.opts[:json_parser_include_request]
82
80
  roda_class.opts[:json_parser_parser].call(*args)
83
81
  end
82
+
83
+
84
+ # Rack 3 dropped requirement that input be rewindable
85
+ if Rack.release >= '2.3'
86
+ # :nocov:
87
+ def _read_json_input(input)
88
+ input.read
89
+ end
90
+ # :nocov:
91
+ else
92
+ def _read_json_input(input)
93
+ input.rewind
94
+ str = input.read
95
+ input.rewind
96
+ str
97
+ end
98
+ end
84
99
  end
85
100
  end
86
101
 
@@ -58,6 +58,10 @@ class Roda
58
58
  # end
59
59
  # end
60
60
  module MultiPublic
61
+ # :nocov:
62
+ RACK_FILES = defined?(Rack::Files) ? Rack::Files : Rack::File
63
+ # :nocov:
64
+
61
65
  def self.load_dependencies(app, _, opts=OPTS)
62
66
  app.plugin(:public, opts)
63
67
  end
@@ -67,7 +71,7 @@ class Roda
67
71
  roots = app.opts[:multi_public_servers] = (app.opts[:multi_public_servers] || {}).dup
68
72
  directories.each do |key, path|
69
73
  path, headers, mime = path
70
- roots[key] = ::Rack::File.new(app.expand_path(path), headers||{}, mime||'text/plain')
74
+ roots[key] = RACK_FILES.new(app.expand_path(path), headers||{}, mime||'text/plain')
71
75
  end
72
76
  roots.freeze
73
77
  end
@@ -37,6 +37,9 @@ class Roda
37
37
  module Public
38
38
  SPLIT = Regexp.union(*[File::SEPARATOR, File::ALT_SEPARATOR].compact)
39
39
  PARSER = URI::DEFAULT_PARSER
40
+ # :nocov:
41
+ RACK_FILES = defined?(Rack::Files) ? Rack::Files : Rack::File
42
+ # :nocov:
40
43
 
41
44
  # Use options given to setup a Rack::File instance for serving files. Options:
42
45
  # :default_mime :: The default mime type to use if the mime type is not recognized.
@@ -52,7 +55,7 @@ class Roda
52
55
  elsif !app.opts[:public_root]
53
56
  app.opts[:public_root] = app.expand_path("public")
54
57
  end
55
- app.opts[:public_server] = ::Rack::File.new(app.opts[:public_root], opts[:headers]||{}, opts[:default_mime] || 'text/plain')
58
+ app.opts[:public_server] = RACK_FILES.new(app.opts[:public_root], opts[:headers]||{}, opts[:default_mime] || 'text/plain')
56
59
  app.opts[:public_gzip] = opts[:gzip]
57
60
  app.opts[:public_brotli] = opts[:brotli]
58
61
  end
@@ -99,7 +102,10 @@ class Roda
99
102
  public_serve_compressed(server, path, '.gz', 'gzip') if roda_opts[:public_gzip]
100
103
 
101
104
  if public_file_readable?(path)
102
- halt public_serve(server, path)
105
+ s, h, b = public_serve(server, path)
106
+ headers = response.headers
107
+ headers.replace(h)
108
+ halt [s, headers, b]
103
109
  end
104
110
  end
105
111
 
@@ -108,21 +114,22 @@ class Roda
108
114
  compressed_path = path + suffix
109
115
 
110
116
  if public_file_readable?(compressed_path)
111
- res = public_serve(server, compressed_path)
112
- headers = res[1]
117
+ s, h, b = public_serve(server, compressed_path)
118
+ headers = response.headers
119
+ headers.replace(h)
113
120
 
114
- unless res[0] == 304
121
+ unless s == 304
115
122
  headers['Content-Type'] = ::Rack::Mime.mime_type(::File.extname(path), 'text/plain')
116
123
  headers['Content-Encoding'] = encoding
117
124
  end
118
125
 
119
- halt res
126
+ halt [s, headers, b]
120
127
  end
121
128
  end
122
129
  end
123
130
 
124
131
  if ::Rack.release > '2'
125
- # Serve the given path using the given Rack::File server.
132
+ # Serve the given path using the given Rack::Files server.
126
133
  def public_serve(server, path)
127
134
  server.serving(self, path)
128
135
  end
@@ -191,7 +191,9 @@ class Roda
191
191
  when :raise
192
192
  raise InvalidToken, msg
193
193
  when :empty_403
194
- throw :halt, [403, {'Content-Type'=>'text/html', 'Content-Length'=>'0'}, []]
194
+ @_response.status = 403
195
+ @_response.headers.replace('Content-Type'=>'text/html', 'Content-Length'=>'0')
196
+ throw :halt, @_response.finish_with_body([])
195
197
  when :clear_session
196
198
  session.clear
197
199
  when :csrf_failure_method
@@ -35,7 +35,13 @@ class Roda
35
35
  def run(app, opts=OPTS)
36
36
  res = catch(:halt){super(app)}
37
37
  yield res if defined?(yield)
38
- throw(:halt, res) unless opts[:not_found] == :pass && res[0] == 404
38
+ if opts[:not_found] == :pass && res[0] == 404
39
+ body = res[2]
40
+ body.close if body.respond_to?(:close)
41
+ nil
42
+ else
43
+ throw(:halt, res)
44
+ end
39
45
  end
40
46
  end
41
47
  end
@@ -215,6 +215,10 @@ class Roda
215
215
  ISO88591_ENCODING = Encoding.find('ISO-8859-1')
216
216
  BINARY_ENCODING = Encoding.find('BINARY')
217
217
 
218
+ # :nocov:
219
+ RACK_FILES = defined?(Rack::Files) ? Rack::Files : Rack::File
220
+ # :nocov:
221
+
218
222
  # Depend on the status_303 plugin.
219
223
  def self.load_dependencies(app, _opts = nil)
220
224
  app.plugin :status_303
@@ -333,7 +337,7 @@ class Roda
333
337
  last_modified(lm)
334
338
  end
335
339
 
336
- file = ::Rack::File.new nil
340
+ file = RACK_FILES.new nil
337
341
  s, h, b = if Rack.release > '2'
338
342
  file.serving(self, path)
339
343
  else
data/lib/roda/response.rb CHANGED
@@ -37,11 +37,22 @@ class Roda
37
37
  # code for non-empty responses and a 404 code for empty responses.
38
38
  attr_accessor :status
39
39
 
40
- # Set the default headers when creating a response.
41
- def initialize
42
- @headers = {}
43
- @body = []
44
- @length = 0
40
+ # :nocov:
41
+ if defined?(Rack::Headers) && Rack::Headers.is_a?(Class)
42
+ # Set the default headers when creating a response.
43
+ def initialize
44
+ @headers = Rack::Headers.new
45
+ @body = []
46
+ @length = 0
47
+ end
48
+ else
49
+ # :nocov:
50
+ # Set the default headers when creating a response.
51
+ def initialize
52
+ @headers = {}
53
+ @body = []
54
+ @length = 0
55
+ end
45
56
  end
46
57
 
47
58
  # Return the response header with the given key. Example:
@@ -96,8 +107,7 @@ class Roda
96
107
  if (s == 304 || s == 204 || (s >= 100 && s <= 199))
97
108
  h.delete("Content-Type")
98
109
  elsif s == 205
99
- h.delete("Content-Type")
100
- h["Content-Length"] = '0'
110
+ empty_205_headers(h)
101
111
  else
102
112
  h["Content-Length"] ||= '0'
103
113
  end
@@ -158,6 +168,23 @@ class Roda
158
168
 
159
169
  private
160
170
 
171
+ # :nocov:
172
+ if Rack.release < '2.0.2'
173
+ # Don't use a content length for empty 205 responses on
174
+ # rack 1, as it violates Rack::Lint in that version.
175
+ def empty_205_headers(headers)
176
+ headers.delete("Content-Type")
177
+ headers.delete("Content-Length")
178
+ end
179
+ # :nocov:
180
+ else
181
+ # Set the content length for empty 205 responses to 0
182
+ def empty_205_headers(headers)
183
+ headers.delete("Content-Type")
184
+ headers["Content-Length"] = '0'
185
+ end
186
+ end
187
+
161
188
  # For each default header, if a header has not already been set for the
162
189
  # response, set the header in the response.
163
190
  def set_default_headers
data/lib/roda/version.rb CHANGED
@@ -4,7 +4,7 @@ class Roda
4
4
  RodaMajorVersion = 3
5
5
 
6
6
  # The minor version of Roda, updated for new feature releases of Roda.
7
- RodaMinorVersion = 53
7
+ RodaMinorVersion = 54
8
8
 
9
9
  # The patch version of Roda, updated only for bug fixes from the last
10
10
  # feature release.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roda
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.53.0
4
+ version: 3.54.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Evans
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-14 00:00:00.000000000 Z
11
+ date: 2022-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -211,6 +211,7 @@ extra_rdoc_files:
211
211
  - doc/release_notes/3.51.0.txt
212
212
  - doc/release_notes/3.52.0.txt
213
213
  - doc/release_notes/3.53.0.txt
214
+ - doc/release_notes/3.54.0.txt
214
215
  - doc/release_notes/3.6.0.txt
215
216
  - doc/release_notes/3.7.0.txt
216
217
  - doc/release_notes/3.8.0.txt
@@ -271,6 +272,7 @@ files:
271
272
  - doc/release_notes/3.51.0.txt
272
273
  - doc/release_notes/3.52.0.txt
273
274
  - doc/release_notes/3.53.0.txt
275
+ - doc/release_notes/3.54.0.txt
274
276
  - doc/release_notes/3.6.0.txt
275
277
  - doc/release_notes/3.7.0.txt
276
278
  - doc/release_notes/3.8.0.txt
@@ -416,7 +418,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
416
418
  - !ruby/object:Gem::Version
417
419
  version: '0'
418
420
  requirements: []
419
- rubygems_version: 3.3.3
421
+ rubygems_version: 3.3.7
420
422
  signing_key:
421
423
  specification_version: 4
422
424
  summary: Routing tree web toolkit