IOWA 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CONTRIBUTORS +14 -0
- data/README.md +23 -0
- data/RELEASE_NOTES +77 -0
- data/ToDo +21 -0
- data/components/CRUDList/CRUDList.html +13 -0
- data/components/CRUDList/CRUDList.iwa +136 -0
- data/components/Content/Content.html +0 -0
- data/components/Content/Content.iwa +143 -0
- data/components/Content/example/README +9 -0
- data/components/Content/example/cgi/iowa.cgi +10 -0
- data/components/Content/example/demo.rb +30 -0
- data/components/Content/example/doc/index.html +7 -0
- data/components/Content/example/iowa/Content.html +1 -0
- data/components/Content/example/iowa/Content.iwa +1 -0
- data/components/Content/example/iowa/Main.html +6 -0
- data/components/Content/example/iowa/Main.iwa +3 -0
- data/components/Content/example/iowa/_content/body +7 -0
- data/components/Content/example/iowa/_content/body2 +3 -0
- data/components/Content/example/iowa/_content/title +2 -0
- data/components/Content/example/iowa/app.cnf +8 -0
- data/components/Content/example/iowa/app.rb +8 -0
- data/components/Content/example/webrick.rb +38 -0
- data/components/Include/Include.html +1 -0
- data/components/Include/Include.iwa +30 -0
- data/components/Include/readme +5 -0
- data/components/JumpTo/JumpTo.html +8 -0
- data/components/JumpTo/JumpTo.iwa +8 -0
- data/components/JumpTo/readme +6 -0
- data/doc/Architecture.txt +6 -0
- data/doc/History.txt +33 -0
- data/doc/StandardDispatcher.txt +19 -0
- data/examples/blog/README +1 -0
- data/examples/hello_world/README +17 -0
- data/examples/hello_world/htdocs/hello_world_html.html +24 -0
- data/examples/hello_world/htdocs/hello_world_ruby.html +41 -0
- data/examples/hello_world/iowa/HelloWorld.html +14 -0
- data/examples/hello_world/iowa/HelloWorld.iwa +31 -0
- data/examples/hello_world/iowa/Index.html +16 -0
- data/examples/hello_world/iowa/Index.iwa +5 -0
- data/examples/hello_world/iowa/iowa_hello_world.cnf +19 -0
- data/examples/hello_world/iowa/iowa_hello_world.rb +5 -0
- data/examples/hello_world/iowa/mapfile.cnf +6 -0
- data/examples/hw1/iowa/Main.html +1 -0
- data/examples/hw1/iowa/README +9 -0
- data/examples/hw1/iowa/hw.rb +4 -0
- data/examples/hw2/iowa/Main.html +10 -0
- data/examples/hw2/iowa/Main.iwa +7 -0
- data/examples/hw2/iowa/README +16 -0
- data/examples/hw2/iowa/hw.rb +4 -0
- data/examples/hw3/iowa/Main.html +11 -0
- data/examples/hw3/iowa/Main.iwa +7 -0
- data/examples/hw3/iowa/README +22 -0
- data/examples/hw3/iowa/hw.rb +4 -0
- data/examples/hw4/iowa/Greetings.html +10 -0
- data/examples/hw4/iowa/Greetings.iwa +9 -0
- data/examples/hw4/iowa/Main.html +12 -0
- data/examples/hw4/iowa/Main.iwa +10 -0
- data/examples/hw4/iowa/README +28 -0
- data/examples/hw4/iowa/hw.rb +4 -0
- data/examples/hw5/iowa/Footer.html +2 -0
- data/examples/hw5/iowa/Greetings.html +4 -0
- data/examples/hw5/iowa/Greetings.iwa +12 -0
- data/examples/hw5/iowa/Header.html +6 -0
- data/examples/hw5/iowa/Main.html +12 -0
- data/examples/hw5/iowa/Main.iwa +13 -0
- data/examples/hw5/iowa/README +16 -0
- data/examples/hw5/iowa/hw.rb +4 -0
- data/examples/template_server/iowa/Content.iwa +121 -0
- data/examples/template_server/iowa/Content.view +0 -0
- data/examples/template_server/iowa/DBContentDispatcher.rb +112 -0
- data/examples/template_server/iowa/DBContentPage.html +3 -0
- data/examples/template_server/iowa/DBContentPage.iwa +85 -0
- data/examples/template_server/iowa/app.cnf +13 -0
- data/examples/template_server/iowa/app.rb +5 -0
- data/ext/Classifier/classifier.c +256 -0
- data/ext/Classifier/ext_help.h +14 -0
- data/ext/Classifier/extconf.rb +5 -0
- data/ext/Classifier/tst.h +40 -0
- data/ext/Classifier/tst_cleanup.c +24 -0
- data/ext/Classifier/tst_delete.c +146 -0
- data/ext/Classifier/tst_grow_node_free_list.c +38 -0
- data/ext/Classifier/tst_init.c +41 -0
- data/ext/Classifier/tst_insert.c +192 -0
- data/ext/Classifier/tst_search.c +68 -0
- data/ext/http11/README +11 -0
- data/ext/http11/ext_help.h +15 -0
- data/ext/http11/extconf.rb +5 -0
- data/ext/http11/http11.c +534 -0
- data/ext/http11/http11.c.dif +422 -0
- data/ext/http11/http11_parser.c +1243 -0
- data/ext/http11/http11_parser.c.dif +193 -0
- data/ext/http11/http11_parser.h +49 -0
- data/ext/http11/http11_parser.h.dif +20 -0
- data/ext/http11/http11_parser.rl +192 -0
- data/ext/httpmachine/Makefile +149 -0
- data/ext/httpmachine/extconf.rb +33 -0
- data/ext/httpmachine/http.cpp +430 -0
- data/ext/httpmachine/http.h +156 -0
- data/ext/httpmachine/rubyhttp.cpp +165 -0
- data/external/mime-types/LICENCE +18 -0
- data/external/mime-types/README +46 -0
- data/external/mime-types/doc/classes/MIME.html +120 -0
- data/external/mime-types/doc/classes/MIME/InvalidContentType.html +119 -0
- data/external/mime-types/doc/classes/MIME/Type.html +866 -0
- data/external/mime-types/doc/classes/MIME/Type.src/M000010.html +22 -0
- data/external/mime-types/doc/classes/MIME/Type.src/M000011.html +18 -0
- data/external/mime-types/doc/classes/MIME/Type.src/M000012.html +19 -0
- data/external/mime-types/doc/classes/MIME/Type.src/M000013.html +18 -0
- data/external/mime-types/doc/classes/MIME/Type.src/M000014.html +26 -0
- data/external/mime-types/doc/classes/MIME/Type.src/M000015.html +33 -0
- data/external/mime-types/doc/classes/MIME/Type.src/M000016.html +27 -0
- data/external/mime-types/doc/classes/MIME/Type.src/M000017.html +35 -0
- data/external/mime-types/doc/classes/MIME/Type.src/M000018.html +34 -0
- data/external/mime-types/doc/classes/MIME/Type.src/M000019.html +24 -0
- data/external/mime-types/doc/classes/MIME/Type.src/M000020.html +38 -0
- data/external/mime-types/doc/classes/MIME/Type.src/M000021.html +22 -0
- data/external/mime-types/doc/classes/MIME/Type.src/M000022.html +18 -0
- data/external/mime-types/doc/classes/MIME/Type.src/M000023.html +18 -0
- data/external/mime-types/doc/classes/MIME/Type.src/M000024.html +18 -0
- data/external/mime-types/doc/classes/MIME/Type.src/M000025.html +18 -0
- data/external/mime-types/doc/classes/MIME/Type.src/M000026.html +18 -0
- data/external/mime-types/doc/classes/MIME/Type.src/M000027.html +18 -0
- data/external/mime-types/doc/classes/MIME/Type.src/M000028.html +18 -0
- data/external/mime-types/doc/classes/MIME/Type.src/M000029.html +18 -0
- data/external/mime-types/doc/classes/MIME/Type.src/M000030.html +19 -0
- data/external/mime-types/doc/classes/MIME/Type.src/M000031.html +26 -0
- data/external/mime-types/doc/classes/MIME/Types.html +459 -0
- data/external/mime-types/doc/classes/MIME/Types.src/M000001.html +19 -0
- data/external/mime-types/doc/classes/MIME/Types.src/M000002.html +32 -0
- data/external/mime-types/doc/classes/MIME/Types.src/M000003.html +21 -0
- data/external/mime-types/doc/classes/MIME/Types.src/M000004.html +18 -0
- data/external/mime-types/doc/classes/MIME/Types.src/M000005.html +26 -0
- data/external/mime-types/doc/classes/MIME/Types.src/M000006.html +18 -0
- data/external/mime-types/doc/classes/MIME/Types.src/M000007.html +18 -0
- data/external/mime-types/doc/classes/MIME/Types.src/M000008.html +18 -0
- data/external/mime-types/doc/classes/MIME/Types.src/M000009.html +18 -0
- data/external/mime-types/doc/created.rid +1 -0
- data/external/mime-types/doc/files/ChangeLog.html +320 -0
- data/external/mime-types/doc/files/README.html +145 -0
- data/external/mime-types/doc/files/lib/mime/types_rb.html +101 -0
- data/external/mime-types/doc/fr_class_index.html +30 -0
- data/external/mime-types/doc/fr_file_index.html +29 -0
- data/external/mime-types/doc/fr_method_index.html +57 -0
- data/external/mime-types/doc/index.html +24 -0
- data/external/mime-types/doc/rdoc-style.css +208 -0
- data/external/mime-types/lib/mime/types.rb +1558 -0
- data/external/package.rb +672 -0
- data/external/test_support.rb +95 -0
- data/external/tmail/README +7 -0
- data/external/tmail/tmail.rb +4 -0
- data/external/tmail/tmail/address.rb +222 -0
- data/external/tmail/tmail/base64.rb +52 -0
- data/external/tmail/tmail/compat.rb +39 -0
- data/external/tmail/tmail/config.rb +50 -0
- data/external/tmail/tmail/encode.rb +447 -0
- data/external/tmail/tmail/header.rb +895 -0
- data/external/tmail/tmail/info.rb +14 -0
- data/external/tmail/tmail/loader.rb +1 -0
- data/external/tmail/tmail/mail.rb +869 -0
- data/external/tmail/tmail/mailbox.rb +386 -0
- data/external/tmail/tmail/mbox.rb +1 -0
- data/external/tmail/tmail/net.rb +260 -0
- data/external/tmail/tmail/obsolete.rb +123 -0
- data/external/tmail/tmail/parser.rb +1475 -0
- data/external/tmail/tmail/parser.y +372 -0
- data/external/tmail/tmail/port.rb +356 -0
- data/external/tmail/tmail/scanner.rb +17 -0
- data/external/tmail/tmail/scanner_r.rb +243 -0
- data/external/tmail/tmail/stringio.rb +256 -0
- data/external/tmail/tmail/textutils.rb +197 -0
- data/external/tmail/tmail/tmail.rb +1 -0
- data/external/tmail/tmail/utils.rb +23 -0
- data/external/win32-process/README +133 -0
- data/external/win32-process/lib/win32/process.rb +561 -0
- data/external/windows-pr/README +145 -0
- data/external/windows-pr/doc/conversion_guide.txt +25 -0
- data/external/windows-pr/lib/windows/clipboard.rb +72 -0
- data/external/windows-pr/lib/windows/console.rb +323 -0
- data/external/windows-pr/lib/windows/device_io.rb +88 -0
- data/external/windows-pr/lib/windows/directory.rb +80 -0
- data/external/windows-pr/lib/windows/error.rb +313 -0
- data/external/windows-pr/lib/windows/eventlog.rb +120 -0
- data/external/windows-pr/lib/windows/file.rb +349 -0
- data/external/windows-pr/lib/windows/filesystem.rb +16 -0
- data/external/windows-pr/lib/windows/handle.rb +31 -0
- data/external/windows-pr/lib/windows/library.rb +76 -0
- data/external/windows-pr/lib/windows/limits.rb +13 -0
- data/external/windows-pr/lib/windows/memory.rb +117 -0
- data/external/windows-pr/lib/windows/msvcrt/buffer.rb +48 -0
- data/external/windows-pr/lib/windows/msvcrt/file.rb +18 -0
- data/external/windows-pr/lib/windows/msvcrt/string.rb +46 -0
- data/external/windows-pr/lib/windows/national.rb +557 -0
- data/external/windows-pr/lib/windows/path.rb +296 -0
- data/external/windows-pr/lib/windows/pipe.rb +77 -0
- data/external/windows-pr/lib/windows/process.rb +171 -0
- data/external/windows-pr/lib/windows/registry.rb +238 -0
- data/external/windows-pr/lib/windows/security.rb +89 -0
- data/external/windows-pr/lib/windows/service.rb +183 -0
- data/external/windows-pr/lib/windows/shell.rb +88 -0
- data/external/windows-pr/lib/windows/sound.rb +52 -0
- data/external/windows-pr/lib/windows/synchronize.rb +161 -0
- data/external/windows-pr/lib/windows/system_info.rb +70 -0
- data/external/windows-pr/lib/windows/unicode.rb +138 -0
- data/external/windows-pr/lib/windows/window.rb +22 -0
- data/iowa.gemspec +45 -0
- data/microprojects/DiskCache/LICENSE +28 -0
- data/microprojects/DiskCache/README +17 -0
- data/microprojects/DiskCache/external/package.rb +608 -0
- data/microprojects/DiskCache/external/test_support.rb +8 -0
- data/microprojects/DiskCache/setup.rb +22 -0
- data/microprojects/DiskCache/src/iowa/Association.rb +67 -0
- data/microprojects/DiskCache/src/iowa/Constants.rb +159 -0
- data/microprojects/DiskCache/src/iowa/DiskStore.rb +377 -0
- data/microprojects/DiskCache/src/iowa/Hash.rb +63 -0
- data/microprojects/DiskCache/src/iowa/Lockfile.rb +575 -0
- data/microprojects/DiskCache/src/iowa/Mutex.rb +142 -0
- data/microprojects/DiskCache/src/iowa/caches/DiskCache.rb +605 -0
- data/microprojects/DiskCache/src/iowa/caches/LRUCache.rb +287 -0
- data/microprojects/DiskCache/test/TC_DiskCache.rb +218 -0
- data/microprojects/LRUCache/LICENSE +28 -0
- data/microprojects/LRUCache/README +13 -0
- data/microprojects/LRUCache/external/package.rb +608 -0
- data/microprojects/LRUCache/external/test_support.rb +8 -0
- data/microprojects/LRUCache/setup.rb +22 -0
- data/microprojects/LRUCache/src/iowa/Association.rb +57 -0
- data/microprojects/LRUCache/src/iowa/Constants.rb +159 -0
- data/microprojects/LRUCache/src/iowa/Hash.rb +63 -0
- data/microprojects/LRUCache/src/iowa/Mutex.rb +129 -0
- data/microprojects/LRUCache/src/iowa/caches/LRUCache.rb +287 -0
- data/microprojects/LRUCache/test/TC_LRUCache.rb +65 -0
- data/microprojects/LinkedList/LICENSE +28 -0
- data/microprojects/LinkedList/README +13 -0
- data/microprojects/LinkedList/external/package.rb +608 -0
- data/microprojects/LinkedList/external/test_support.rb +8 -0
- data/microprojects/LinkedList/setup.rb +22 -0
- data/microprojects/LinkedList/src/iowa/LinkedList.rb +165 -0
- data/microprojects/LinkedList/test/TC_LinkedList.rb +42 -0
- data/microprojects/README +8 -0
- data/setup.rb +116 -0
- data/share/iowa/app_skeleton/Main.html +8 -0
- data/share/iowa/app_skeleton/Main.iwa +15 -0
- data/share/iowa/app_skeleton/app.cnf +48 -0
- data/share/iowa/app_skeleton/app.rb +58 -0
- data/share/iowa/app_skeleton/models/model.rb +49 -0
- data/src/ihc.rb +223 -0
- data/src/iowa.cgi +29 -0
- data/src/iowa.rb +637 -0
- data/src/iowa/AbstractCache.rb +96 -0
- data/src/iowa/AcceptLanguage.rb +76 -0
- data/src/iowa/Application.rb +928 -0
- data/src/iowa/ApplicationStats.rb +72 -0
- data/src/iowa/Association.rb +67 -0
- data/src/iowa/BindingsParser.rb +62 -0
- data/src/iowa/Breakpoint.rb +273 -0
- data/src/iowa/CSS.rb +564 -0
- data/src/iowa/Client.rb +192 -0
- data/src/iowa/Component.rb +405 -0
- data/src/iowa/ComponentProxy.rb +26 -0
- data/src/iowa/Config.rb +21 -0
- data/src/iowa/Constants.rb +226 -0
- data/src/iowa/Context.rb +218 -0
- data/src/iowa/ContextLogger.rb +16 -0
- data/src/iowa/DbPool.rb +222 -0
- data/src/iowa/DetachedComponent.rb +18 -0
- data/src/iowa/Dispatcher.rb +27 -0
- data/src/iowa/DynamicElements.rb +471 -0
- data/src/iowa/Element.rb +100 -0
- data/src/iowa/Email.rb +287 -0
- data/src/iowa/Extensions/AllExtensions.rb +4 -0
- data/src/iowa/Extensions/Class.rb +94 -0
- data/src/iowa/Extensions/Date.rb +88 -0
- data/src/iowa/Extensions/DateTime.rb +88 -0
- data/src/iowa/Extensions/Hash.rb +22 -0
- data/src/iowa/Extensions/Kernel.rb +6 -0
- data/src/iowa/Extensions/Numeric.rb +47 -0
- data/src/iowa/Extensions/Object.rb +11 -0
- data/src/iowa/Extensions/String.rb +60 -0
- data/src/iowa/Extensions/Time.rb +89 -0
- data/src/iowa/Extensions/TimeExtensions.rb +6 -0
- data/src/iowa/Form.rb +368 -0
- data/src/iowa/Hash.rb +85 -0
- data/src/iowa/ISAAC.rb +175 -0
- data/src/iowa/ImageSize.rb +279 -0
- data/src/iowa/IowaComponentMixins.rb +7 -0
- data/src/iowa/JSON-lexer.rb +296 -0
- data/src/iowa/JSON-objects.rb +201 -0
- data/src/iowa/KeyValueCoding.rb +91 -0
- data/src/iowa/LinkedList.rb +175 -0
- data/src/iowa/Loader.rb +22 -0
- data/src/iowa/Lockfile.rb +575 -0
- data/src/iowa/Logger.rb +74 -0
- data/src/iowa/Monkey.rb +20 -0
- data/src/iowa/Mutex.rb +142 -0
- data/src/iowa/Policy.rb +70 -0
- data/src/iowa/Pool.rb +243 -0
- data/src/iowa/PrettyException.rb +1091 -0
- data/src/iowa/Request.rb +244 -0
- data/src/iowa/Response.rb +133 -0
- data/src/iowa/Session.rb +354 -0
- data/src/iowa/SessionStats.rb +78 -0
- data/src/iowa/String.rb +65 -0
- data/src/iowa/Tag.rb +101 -0
- data/src/iowa/TemplateParser.rb +236 -0
- data/src/iowa/Util.rb +314 -0
- data/src/iowa/Webcache.rb +122 -0
- data/src/iowa/caches/BiLevelCache.rb +65 -0
- data/src/iowa/caches/ClassLimitedCache.rb +67 -0
- data/src/iowa/caches/DiskCache.rb +609 -0
- data/src/iowa/caches/DiskStore.rb +380 -0
- data/src/iowa/caches/LRUCache-alternative.rb +155 -0
- data/src/iowa/caches/LRUCache.rb +290 -0
- data/src/iowa/caches/SimpleLRUCache.rb +112 -0
- data/src/iowa/dispatchers/StandardDispatcher.rb +396 -0
- data/src/iowa/dispatchers/StandardDispatcherWithClassifier.rb +93 -0
- data/src/iowa/js/iowa_jsonrpc.js +381 -0
- data/src/iowa/js/jsonrpc.js +187 -0
- data/src/iowa/js/jsonrpc_async.js +261 -0
- data/src/iowa/loaders/DiskLoader.rb +50 -0
- data/src/iowa/loggers/Analogger.rb +54 -0
- data/src/iowa/loggers/AsyncLogger.rb +54 -0
- data/src/iowa/loggers/BitBucket.rb +38 -0
- data/src/iowa/loggers/Log4R.rb +13 -0
- data/src/iowa/loggers/Log4rLogger.rb +48 -0
- data/src/iowa/loggers/Logger.rb +29 -0
- data/src/iowa/loggers/RubyLogger.rb +9 -0
- data/src/iowa/pools/DBConnectionPool.rb +53 -0
- data/src/iowa/request/Apache.rb +90 -0
- data/src/iowa/request/EMHybrid.rb +59 -0
- data/src/iowa/request/ENV.rb +80 -0
- data/src/iowa/request/FCGI.rb +68 -0
- data/src/iowa/request/HTTPMachine.rb +75 -0
- data/src/iowa/request/Mongrel.rb +68 -0
- data/src/iowa/request/WEBrick.rb +48 -0
- data/src/iowa/version.rb +3 -0
- data/src/iowa/webrick/HTTPServer.rb +43 -0
- data/src/iowa/webrick/WEBrickServlet.rb +28 -0
- data/src/iowa_fcgi_handler.rb +101 -0
- data/src/iowa_httpmachine.rb +141 -0
- data/src/iowa_hybrid.rb +193 -0
- data/src/iowa_hybrid_cluster.rb +231 -0
- data/src/iowa_mongrel.rb +136 -0
- data/src/iowa_webrick.rb +194 -0
- data/src/iowa_webrick_legacy.rb +104 -0
- data/src/mod_iowa.rb +104 -0
- data/tcss.rb +61 -0
- data/test/README.windows +12 -0
- data/test/TC_AcceptLanguage.rb +61 -0
- data/test/TC_AppConfig.rb +43 -0
- data/test/TC_AppConfig/cgi/iowa.cgi +7 -0
- data/test/TC_AppConfig/doc/index.html +1 -0
- data/test/TC_AppConfig/iowa/Main.html +4 -0
- data/test/TC_AppConfig/iowa/Main.iwa +17 -0
- data/test/TC_AppConfig/iowa/README +1 -0
- data/test/TC_AppConfig/iowa/app.cnf +19 -0
- data/test/TC_AppConfig/iowa/app.rb +8 -0
- data/test/TC_AppConfig/webrick.rb +38 -0
- data/test/TC_Association.rb +29 -0
- data/test/TC_BiLevelCache.rb +71 -0
- data/test/TC_CGI_Adaptor.rb +55 -0
- data/test/TC_CGI_Adaptor/cgi/iowa.cgi +7 -0
- data/test/TC_CGI_Adaptor/doc/index.html +1 -0
- data/test/TC_CGI_Adaptor/iowa/Main.html +8 -0
- data/test/TC_CGI_Adaptor/iowa/Main.iwa +14 -0
- data/test/TC_CGI_Adaptor/iowa/README +1 -0
- data/test/TC_CGI_Adaptor/iowa/app.cnf +8 -0
- data/test/TC_CGI_Adaptor/iowa/app.rb +8 -0
- data/test/TC_CGI_Adaptor/webrick.rb +38 -0
- data/test/TC_CSS.rb +660 -0
- data/test/TC_ClassLimitedCache.rb +89 -0
- data/test/TC_Classifier.rb +80 -0
- data/test/TC_DbPool.rb +127 -0
- data/test/TC_DiskCache.rb +218 -0
- data/test/TC_Hybrid.rb +58 -0
- data/test/TC_Hybrid/doc/thing.txt +1 -0
- data/test/TC_Hybrid/iowa/Main.html +3 -0
- data/test/TC_Hybrid/iowa/Main.iwa +7 -0
- data/test/TC_Hybrid/iowa/NewPage.html +1 -0
- data/test/TC_Hybrid/iowa/NewPage.iwa +5 -0
- data/test/TC_Hybrid/iowa/app.cnf +10 -0
- data/test/TC_Hybrid/iowa/app.rb +5 -0
- data/test/TC_IOWAFunctions/doc/Ajax1.html +1 -0
- data/test/TC_IOWAFunctions/doc/Ajax1.iwa +1 -0
- data/test/TC_IOWAFunctions/doc/index.html +1 -0
- data/test/TC_IOWAFunctions/doc/js/dojo.js +9686 -0
- data/test/TC_IOWAFunctions/iowa/Ajax1.html +40 -0
- data/test/TC_IOWAFunctions/iowa/Ajax1.iwa +23 -0
- data/test/TC_IOWAFunctions/iowa/AjaxWidget.iwa +19 -0
- data/test/TC_IOWAFunctions/iowa/AjaxWidget.view +22 -0
- data/test/TC_IOWAFunctions/iowa/DanielTest.html +9 -0
- data/test/TC_IOWAFunctions/iowa/DanielTest.iwa +10 -0
- data/test/TC_IOWAFunctions/iowa/IntervalWidget.html +1 -0
- data/test/TC_IOWAFunctions/iowa/IntervalWidget.iwa +14 -0
- data/test/TC_IOWAFunctions/iowa/Main.html +1 -0
- data/test/TC_IOWAFunctions/iowa/NestedRepeat1.html +12 -0
- data/test/TC_IOWAFunctions/iowa/NestedRepeat1.iwa +24 -0
- data/test/TC_IOWAFunctions/iowa/RPCResponse.iwa +7 -0
- data/test/TC_IOWAFunctions/iowa/RPCResponse.view +1 -0
- data/test/TC_IOWAFunctions/iowa/Repeat1.iwa +31 -0
- data/test/TC_IOWAFunctions/iowa/Repeat1.view +9 -0
- data/test/TC_IOWAFunctions/iowa/Repeat2.iwa +32 -0
- data/test/TC_IOWAFunctions/iowa/Repeat2.view +11 -0
- data/test/TC_IOWAFunctions/iowa/Repeat3.iwa +44 -0
- data/test/TC_IOWAFunctions/iowa/Repeat3.view +18 -0
- data/test/TC_IOWAFunctions/iowa/TesCon.html +1 -0
- data/test/TC_IOWAFunctions/iowa/TesCon.iwa +5 -0
- data/test/TC_IOWAFunctions/iowa/app.cnf +19 -0
- data/test/TC_IOWAFunctions/iowa/app.rb +9 -0
- data/test/TC_IOWAFunctions/iowa/mapfile.cnf +8 -0
- data/test/TC_ISAAC.rb +52 -0
- data/test/TC_ImageSize.rb +84 -0
- data/test/TC_ImageSize/img.bmp +0 -0
- data/test/TC_ImageSize/img.gif +0 -0
- data/test/TC_ImageSize/img.jpg +0 -0
- data/test/TC_ImageSize/img.pcx +0 -0
- data/test/TC_ImageSize/img.pgm +7144 -0
- data/test/TC_ImageSize/img.png +0 -0
- data/test/TC_ImageSize/img.ppm +0 -0
- data/test/TC_ImageSize/img.psd +0 -0
- data/test/TC_ImageSize/img.tiff +0 -0
- data/test/TC_ImageSize/img.xbm +22 -0
- data/test/TC_KeyValueCoding.rb +35 -0
- data/test/TC_LRUCache.rb +296 -0
- data/test/TC_LinkedList.rb +46 -0
- data/test/TC_Lockfile.rb +106 -0
- data/test/TC_Minimal.rb +45 -0
- data/test/TC_Minimal/app.cnf +8 -0
- data/test/TC_Minimal/cgi-bin/iowa.cgi +11 -0
- data/test/TC_Minimal/doc/index.html +1 -0
- data/test/TC_Minimal/iowa/Main.html +1 -0
- data/test/TC_Minimal/iowa/README +1 -0
- data/test/TC_Minimal/iowa/app.rb +3 -0
- data/test/TC_Minimal/webrick.rb +38 -0
- data/test/TC_Mongrel.rb +58 -0
- data/test/TC_Mongrel/doc/thing.txt +1 -0
- data/test/TC_Mongrel/iowa/Main.html +3 -0
- data/test/TC_Mongrel/iowa/Main.iwa +7 -0
- data/test/TC_Mongrel/iowa/NewPage.html +1 -0
- data/test/TC_Mongrel/iowa/NewPage.iwa +5 -0
- data/test/TC_Mongrel/iowa/app.cnf +10 -0
- data/test/TC_Mongrel/iowa/app.rb +5 -0
- data/test/TC_NoSubclass.rb +56 -0
- data/test/TC_NoSubclass/cgi/iowa.cgi +7 -0
- data/test/TC_NoSubclass/doc/index.html +1 -0
- data/test/TC_NoSubclass/iowa/Main.html +8 -0
- data/test/TC_NoSubclass/iowa/Main.iwa +14 -0
- data/test/TC_NoSubclass/iowa/README +1 -0
- data/test/TC_NoSubclass/iowa/app.cnf +8 -0
- data/test/TC_NoSubclass/iowa/app.rb +5 -0
- data/test/TC_NoSubclass/webrick.rb +38 -0
- data/test/TC_Pool.rb +139 -0
- data/test/TC_RenderedCache/doc/thing.txt +1 -0
- data/test/TC_RenderedCache/iowa/BigPage.html +1 -0
- data/test/TC_RenderedCache/iowa/BigPage.iwa +12 -0
- data/test/TC_RenderedCache/iowa/Main.html +3 -0
- data/test/TC_RenderedCache/iowa/Main.iwa +7 -0
- data/test/TC_RenderedCache/iowa/NewPage.html +1 -0
- data/test/TC_RenderedCache/iowa/NewPage.iwa +11 -0
- data/test/TC_RenderedCache/iowa/app.cnf +13 -0
- data/test/TC_RenderedCache/iowa/app.rb +5 -0
- data/test/TC_RenderedCache/iowa/mapfile.map +4 -0
- data/test/TC_ResourceURL.rb +73 -0
- data/test/TC_ResourceURL/iowa/Main.html +2 -0
- data/test/TC_ResourceURL/iowa/Main.iwa +10 -0
- data/test/TC_ResourceURL/iowa/app.cnf +10 -0
- data/test/TC_ResourceURL/iowa/app.rb +5 -0
- data/test/TC_SimpleDetached.rb +41 -0
- data/test/TC_StandardDispatcher.rb +362 -0
- data/test/TC_StandardDispatcherWithClassifier.rb +358 -0
- data/test/TC_String.rb +24 -0
- data/test/TC_Tag.rb +41 -0
- data/test/TC_Webrick.rb +56 -0
- data/test/TC_Webrick/doc/thing.txt +1 -0
- data/test/TC_Webrick/iowa/Main.html +3 -0
- data/test/TC_Webrick/iowa/Main.iwa +7 -0
- data/test/TC_Webrick/iowa/NewPage.html +1 -0
- data/test/TC_Webrick/iowa/NewPage.iwa +5 -0
- data/test/TC_Webrick/iowa/app.cnf +10 -0
- data/test/TC_Webrick/iowa/app.rb +5 -0
- data/test/tc_template.rb +15 -0
- data/test/tests.conf +19 -0
- data/utils/CVS/Entries +3 -0
- data/utils/CVS/Repository +1 -0
- data/utils/CVS/Root +1 -0
- data/utils/QuickCert-1.0.2.tar.gz +0 -0
- data/utils/QuickCert-1.0.2/InstalledFiles +7 -0
- data/utils/QuickCert-1.0.2/MANIFEST +10 -0
- data/utils/QuickCert-1.0.2/Makefile +15 -0
- data/utils/QuickCert-1.0.2/README +56 -0
- data/utils/QuickCert-1.0.2/bin/QuickCert +355 -0
- data/utils/QuickCert-1.0.2/config.save +12 -0
- data/utils/QuickCert-1.0.2/data/examples/ruby/QuickCert/README +60 -0
- data/utils/QuickCert-1.0.2/data/examples/ruby/QuickCert/drbssl_c.rb +26 -0
- data/utils/QuickCert-1.0.2/data/examples/ruby/QuickCert/drbssl_s.rb +35 -0
- data/utils/QuickCert-1.0.2/data/examples/ruby/QuickCert/qc_config +21 -0
- data/utils/QuickCert-1.0.2/lib/QuickCert/defaults.rb +28 -0
- data/utils/QuickCert-1.0.2/setup.rb +1312 -0
- data/utils/iowa_apps +422 -0
- data/utils/smtp_sink.rb +9 -0
- data/utils/startup_template.cnf +27 -0
- data/utils/startup_template.rb +73 -0
- metadata +551 -0
@@ -0,0 +1,141 @@
|
|
1
|
+
Iowa.runmode = :httpmachine
|
2
|
+
require 'rubygems'
|
3
|
+
require 'eventmachine'
|
4
|
+
require 'evma_httpserver'
|
5
|
+
require 'iowa/Client'
|
6
|
+
require 'iowa/request/HTTPMachine'
|
7
|
+
|
8
|
+
module Iowa
|
9
|
+
class HttpEventMachine < ::EventMachine::Connection
|
10
|
+
include ::EventMachine::HttpServer
|
11
|
+
|
12
|
+
def initialize(*args)
|
13
|
+
@iowa_client = Iowa::InlineClient.new(nil,nil)
|
14
|
+
super
|
15
|
+
end
|
16
|
+
|
17
|
+
def deliver_file(filename, suffix)
|
18
|
+
send_data "HTTP/1.1 200 OK\r\n"
|
19
|
+
d = File.read(filename)
|
20
|
+
ct = MIME::Types.type_for(filename).first
|
21
|
+
send_data "Connection: close\r\n"
|
22
|
+
send_data "Date: #{Time.now.httpdate}\r\n"
|
23
|
+
send_data "Content-Type: #{ct ? ct.content_type : 'application/octet-stream'}\r\n"
|
24
|
+
send_data "Content-Length: #{d.length}\r\n\r\n"
|
25
|
+
send_data d
|
26
|
+
close_connection_after_writing
|
27
|
+
Logger['iowa_log'].info "Delivered static file: #{filename}"
|
28
|
+
end
|
29
|
+
|
30
|
+
def handle_file(path_info)
|
31
|
+
if path_info == '/' or path_info == ''
|
32
|
+
path_info = '/index.html'
|
33
|
+
elsif path_info =~ /^([^.]+)$/
|
34
|
+
path_info = "#{$1}/index.html"
|
35
|
+
end
|
36
|
+
|
37
|
+
qsfilename = "#{Iowa.config[Iowa::Capplication][Iowa::Cdoc_root]}#{path_info}__#{ENV['QUERY_STRING']}"
|
38
|
+
filename = "#{Iowa.config[Iowa::Capplication][Iowa::Cdoc_root]}#{path_info}"
|
39
|
+
|
40
|
+
if (FileTest.exist?(qsfilename) and File.expand_path(qsfilename).index(Iowa.config[Iowa::Capplication][Iowa::Cdoc_root]) == 0)
|
41
|
+
deliver_file(qsfilename, path_info.sub(/_*$/,'').split(/\./).last)
|
42
|
+
true
|
43
|
+
elsif (FileTest.exist?(filename) and File.expand_path(filename).index(Iowa.config[Iowa::Capplication][Iowa::Cdoc_root]) == 0)
|
44
|
+
deliver_file(filename, path_info.sub(/_*$/,'').split(/\./).last)
|
45
|
+
true
|
46
|
+
else
|
47
|
+
false
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def process_http_request
|
52
|
+
unless handle_file(@http_path_info)
|
53
|
+
request = Iowa::Request::HTTPMachine.new([@http_request_method, @http_request_uri, @http_headers])
|
54
|
+
response = Iowa.handleConnection request
|
55
|
+
@iowa_client.reset(request,response)
|
56
|
+
send_data "HTTP/1.1 #{response.status_line}\r\n"
|
57
|
+
@iowa_client.print(self)
|
58
|
+
close_connection_after_writing
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def print(data)
|
63
|
+
send_data data
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
module Iowa
|
70
|
+
|
71
|
+
# Handle the communications coming in on the monitored socket,
|
72
|
+
# create a context object from the data received, and then pass
|
73
|
+
# the context information into the Application object for final
|
74
|
+
# handling. Exception handling is simply via capturing the Exception
|
75
|
+
# and outputting a stack backtrace (this could be improved).
|
76
|
+
|
77
|
+
def self.handleConnection(request)
|
78
|
+
start_time = read_time = Time.now
|
79
|
+
mylog = Logger[Ciowa_log]
|
80
|
+
|
81
|
+
status = []
|
82
|
+
response = handleRequest(request)
|
83
|
+
begin
|
84
|
+
response.status_line = request.status_line if request.status_line
|
85
|
+
response.content_type = request.content_type if request.content_type
|
86
|
+
status[0] = response.status_line
|
87
|
+
if request.headers_out.respond_to?(:length) and request.headers_out.length > 0
|
88
|
+
request.headers_out.each {|k,v| response.headers.set(k,v)}
|
89
|
+
end
|
90
|
+
rescue Exception => e
|
91
|
+
mylog.info e.to_s, e.backtrace.inspect
|
92
|
+
end
|
93
|
+
|
94
|
+
end_time = Time.now
|
95
|
+
logline = "#{start_time} (#{read_time - start_time}/#{end_time - start_time}) :: #{request.uri} \"#{status[0]}\" #{response.body.length}B"
|
96
|
+
mylog.info logline
|
97
|
+
response
|
98
|
+
end
|
99
|
+
|
100
|
+
# Outputs the location of the socket being monitored, then enters the
|
101
|
+
# event loop to wait for and handle connections.
|
102
|
+
|
103
|
+
def self.eventLoop
|
104
|
+
Logger[Ciowa_log].info 'Entering the httpmachine event loop...'
|
105
|
+
::EventMachine.run {
|
106
|
+
::EventMachine.start_server(@config[Csocket][Chostname], @config[Csocket][Cport], ::Iowa::HttpEventMachine)
|
107
|
+
}
|
108
|
+
end
|
109
|
+
|
110
|
+
def self.run(*args)
|
111
|
+
run_check_started(*args)
|
112
|
+
mylog = Logger[Ciowa_log]
|
113
|
+
my_ip = @config[Csocket][Chostname]
|
114
|
+
my_ip_hex = my_ip.split('.',4).collect {|x| to_hex(x)}.join
|
115
|
+
|
116
|
+
if @config[Csocket].has_key? Cport
|
117
|
+
socket_host = @config[Csocket][Chostname]
|
118
|
+
socket_port = @config[Csocket][Cport]
|
119
|
+
my_port_hex = sprintf('%04s',socket_port.to_i.to_s(16)).gsub(' ','0')
|
120
|
+
Iowa.app.location = "#{my_ip_hex}#{my_port_hex}"
|
121
|
+
else
|
122
|
+
if Iowa.app.serial_number.to_s != ''
|
123
|
+
Iowa.app.location = "00000000#{sprintf('%04s',Iowa.app.serial_number.to_i.to_s(16)).gsub(' ','0')}"
|
124
|
+
else
|
125
|
+
Iowa.app.location = ''
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
app.initialLoad()
|
130
|
+
@server = nil
|
131
|
+
setup_signal_handlers
|
132
|
+
|
133
|
+
begin
|
134
|
+
eventLoop
|
135
|
+
rescue Exception => exception
|
136
|
+
mylog.fatal "Catastrophic failure in main event loop: #{exception} :: " + exception.backtrace.join(".....").to_s
|
137
|
+
ensure
|
138
|
+
File.delete(@config[Csocket][Cpath]) if @config[Csocket].has_key? Cpath
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
data/src/iowa_hybrid.rb
ADDED
@@ -0,0 +1,193 @@
|
|
1
|
+
Iowa.runmode = :emhybrid
|
2
|
+
require 'eventmachine'
|
3
|
+
require 'iowa/http11'
|
4
|
+
require 'iowa/Client'
|
5
|
+
require 'iowa/request/EMHybrid'
|
6
|
+
|
7
|
+
|
8
|
+
module Iowa
|
9
|
+
class EMHybridServer < EventMachine::Connection
|
10
|
+
|
11
|
+
MAX_HEADER = MAX_BODY = 114688
|
12
|
+
CEMHYBRIDSERVER = 'EMHybridServer'.freeze
|
13
|
+
|
14
|
+
def initialize *args
|
15
|
+
super
|
16
|
+
@linebuffer = ''
|
17
|
+
@iowa_client = Iowa::InlineClient.new(nil,nil)
|
18
|
+
end
|
19
|
+
|
20
|
+
def deliver_file(filename, suffix)
|
21
|
+
send_data "HTTP/1.1 200 OK\r\n"
|
22
|
+
d = File.read(filename)
|
23
|
+
ct = MIME::Types.type_for("foo.#{suffix}").first
|
24
|
+
send_data "Connection: close\r\n"
|
25
|
+
send_data "Date: #{Time.now.httpdate}\r\n"
|
26
|
+
send_data "Content-Type: #{ct ? ct.content_type : 'application/octet-stream'}\r\n"
|
27
|
+
send_data "Content-Length: #{d.length}\r\n\r\n"
|
28
|
+
send_data d
|
29
|
+
close_connection_after_writing
|
30
|
+
Logger[Ciowa_log].info "Delivered static file: #{filename}"
|
31
|
+
end
|
32
|
+
|
33
|
+
def handle_file(params)
|
34
|
+
path_info = params[CREQUEST_URI]
|
35
|
+
qs = params[CQUERY_STRING]
|
36
|
+
if path_info == C_slash or path_info == C_empty
|
37
|
+
path_info = C_slashindex_html
|
38
|
+
elsif path_info =~ /^([^.]+)$/
|
39
|
+
path_info = "#{$1}/index.html"
|
40
|
+
end
|
41
|
+
|
42
|
+
qsfilename = "#{Iowa.config[Iowa::Capplication][Iowa::Cdoc_root]}#{path_info}__#{qs}"
|
43
|
+
filename = "#{Iowa.config[Iowa::Capplication][Iowa::Cdoc_root]}#{path_info}"
|
44
|
+
if (FileTest.exist?(filename) and File.expand_path(filename).index(Iowa.config[Iowa::Capplication][Iowa::Cdoc_root]) == 0)
|
45
|
+
suffix = path_info.sub(/[_\s]*$/,C_empty)
|
46
|
+
deliver_file(filename, File.extname(suffix)[1..-1])
|
47
|
+
true
|
48
|
+
elsif qs and (FileTest.exist?(qsfilename) and File.expand_path(qsfilename).index(Iowa.config[Iowa::Capplication][Iowa::Cdoc_root]) == 0)
|
49
|
+
suffix = path_info.sub(/[_\s]*$/,C_empty)
|
50
|
+
deliver_file(qsfilename, File.extname(suffix)[1..-1])
|
51
|
+
true
|
52
|
+
else
|
53
|
+
false
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def post_init
|
58
|
+
@parser = Iowa::HttpParser.new
|
59
|
+
@params = {}
|
60
|
+
@headers = {}
|
61
|
+
@nparsed = 0
|
62
|
+
@request = nil
|
63
|
+
@request_len = nil
|
64
|
+
end
|
65
|
+
|
66
|
+
def unbind
|
67
|
+
# cleanup here
|
68
|
+
end
|
69
|
+
|
70
|
+
def process_http_request(headers,params,buffer)
|
71
|
+
unless handle_file(params)
|
72
|
+
clen = buffer.length - headers[CCONTENT_LENGTH].to_i
|
73
|
+
body = buffer[clen,headers[CCONTENT_LENGTH].to_i]
|
74
|
+
request = Iowa::Request::EMHybrid.new(headers,params,body)
|
75
|
+
response = Iowa.handleConnection request
|
76
|
+
|
77
|
+
@iowa_client.reset(request,response)
|
78
|
+
send_data "HTTP/1.1 #{response.status_line}\r\n"
|
79
|
+
@iowa_client.print(self)
|
80
|
+
close_connection_after_writing
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def print(data)
|
85
|
+
send_data data
|
86
|
+
end
|
87
|
+
|
88
|
+
def receive_data data
|
89
|
+
@linebuffer << data
|
90
|
+
@nparsed = @parser.execute(@headers, @linebuffer, @nparsed) unless @parser.finished?
|
91
|
+
if @parser.finished?
|
92
|
+
if @request_len.nil?
|
93
|
+
@request_len = @nparsed + @headers[CHTTP_CONTENT_LENGTH].to_i
|
94
|
+
if @request_len > MAX_BODY
|
95
|
+
new_buffer = Tempfile.new(CEMHYBRIDSERVER)
|
96
|
+
new_buffer.binmode
|
97
|
+
new_buffer << @linebuffer
|
98
|
+
@linebuffer = new_buffer
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
if @linebuffer.length >= @request_len
|
103
|
+
process_http_request(@headers,@params,@linebuffer)
|
104
|
+
end
|
105
|
+
elsif @linebuffer.length > MAX_HEADER
|
106
|
+
raise MaxHeaderExceeded
|
107
|
+
end
|
108
|
+
rescue => e
|
109
|
+
Logger['iowa_log'].error "Error while reading request: #{e}\n#{e.backtrace.join}"
|
110
|
+
close_connection
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
module Iowa
|
116
|
+
|
117
|
+
# Handle the communications coming in on the monitored socket,
|
118
|
+
# create a context object from the data received, and then pass
|
119
|
+
# the context information into the Application object for final
|
120
|
+
# handling. Exception handling is simply via capturing the Exception
|
121
|
+
# and outputting a stack backtrace (this could be improved).
|
122
|
+
|
123
|
+
class << self
|
124
|
+
remove_method(:handleConnection)
|
125
|
+
remove_method(:eventLoop)
|
126
|
+
remove_method(:run)
|
127
|
+
end
|
128
|
+
|
129
|
+
def self.handleConnection(request)
|
130
|
+
start_time = read_time = Time.now
|
131
|
+
mylog = Logger[Ciowa_log]
|
132
|
+
|
133
|
+
status = []
|
134
|
+
response = handleRequest(request)
|
135
|
+
begin
|
136
|
+
response.status_line = request.status_line if request.status_line
|
137
|
+
response.content_type = request.content_type if request.content_type
|
138
|
+
status[0] = response.status_line
|
139
|
+
if request.headers_out.respond_to?(:length) and request.headers_out.length > 0
|
140
|
+
request.headers_out.each {|k,v| response.headers.set(k,v)}
|
141
|
+
end
|
142
|
+
rescue Exception => e
|
143
|
+
mylog.info e.to_s, e.backtrace.inspect
|
144
|
+
end
|
145
|
+
|
146
|
+
end_time = Time.now
|
147
|
+
logline = "#{start_time} (#{read_time - start_time}/#{end_time - start_time}) :: #{request.uri} \"#{status[0]}\" #{response.body.length}B"
|
148
|
+
mylog.info logline
|
149
|
+
response
|
150
|
+
end
|
151
|
+
|
152
|
+
# Outputs the location of the socket being monitored, then enters the
|
153
|
+
# event loop to wait for and handle connections.
|
154
|
+
|
155
|
+
def self.eventLoop
|
156
|
+
Logger[Ciowa_log].info 'Entering the EMHybrid event loop...'
|
157
|
+
::EventMachine.run {
|
158
|
+
::EventMachine.start_server @config[Csocket][Chostname], @config[Csocket][Cport], EMHybridServer
|
159
|
+
}
|
160
|
+
end
|
161
|
+
|
162
|
+
def self.run(*args)
|
163
|
+
run_check_started(*args)
|
164
|
+
mylog = Logger[Ciowa_log]
|
165
|
+
my_ip = @config[Csocket][Chostname]
|
166
|
+
my_ip_hex = my_ip.split('.',4).collect {|x| to_hex(x)}.join
|
167
|
+
|
168
|
+
if @config[Csocket].has_key? Cport
|
169
|
+
socket_host = @config[Csocket][Chostname]
|
170
|
+
socket_port = @config[Csocket][Cport]
|
171
|
+
my_port_hex = sprintf('%04s',socket_port.to_i.to_s(16)).gsub(' ','0')
|
172
|
+
Iowa.app.location = "#{my_ip_hex}#{my_port_hex}"
|
173
|
+
else
|
174
|
+
if Iowa.app.serial_number.to_s != ''
|
175
|
+
Iowa.app.location = "00000000#{sprintf('%04s',Iowa.app.serial_number.to_i.to_s(16)).gsub(' ','0')}"
|
176
|
+
else
|
177
|
+
Iowa.app.location = ''
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
app.initialLoad()
|
182
|
+
@server = nil
|
183
|
+
setup_signal_handlers
|
184
|
+
|
185
|
+
begin
|
186
|
+
eventLoop
|
187
|
+
rescue Exception => exception
|
188
|
+
mylog.fatal "Catastrophic failure in main event loop: #{exception} :: " + exception.backtrace.join(".....").to_s
|
189
|
+
ensure
|
190
|
+
File.delete(@config[Csocket][Cpath]) if @config[Csocket].has_key? Cpath
|
191
|
+
end
|
192
|
+
end
|
193
|
+
end
|
@@ -0,0 +1,231 @@
|
|
1
|
+
Iowa.runmode = :emhybridcluster
|
2
|
+
require 'digest/sha2'
|
3
|
+
require 'eventmachine'
|
4
|
+
require 'iowa/http11'
|
5
|
+
require 'iowa/Client'
|
6
|
+
require 'iowa/request/EMHybrid'
|
7
|
+
|
8
|
+
# Hmmm.....This lets the code treat a string buffer and a TempFile based buffer the same, but...hmmm...
|
9
|
+
class IO
|
10
|
+
def [](pos,len)
|
11
|
+
self.seek pos
|
12
|
+
self.read len
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
module Iowa
|
17
|
+
class EMHybridClusterServer < EventMachine::Connection
|
18
|
+
|
19
|
+
MAX_HEADER = MAX_BODY = 114688
|
20
|
+
CEMHYBRIDCLUSTERSERVER = 'EMHybridClusterServer'.freeze
|
21
|
+
|
22
|
+
class MaxHeaderExceeded < Exception; end
|
23
|
+
|
24
|
+
def self.connect(hostname = nil,port = nil)
|
25
|
+
@hostname ||= hostname
|
26
|
+
@port ||= port
|
27
|
+
::EventMachine.connect(@hostname, @port, self) do |conn|
|
28
|
+
conn.set_comm_inactivity_timeout 60
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.hostname
|
33
|
+
@hostname
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.port
|
37
|
+
@port
|
38
|
+
end
|
39
|
+
|
40
|
+
def initialize *args
|
41
|
+
super
|
42
|
+
@filecache = Iowa::Caches::LRUCache.new({:maxsize => 10})
|
43
|
+
@iowa_client = Iowa::InlineClient.new(nil,nil)
|
44
|
+
end
|
45
|
+
|
46
|
+
def connection_completed
|
47
|
+
@completed = true
|
48
|
+
key = ::Iowa.config[Capplication].has_key?(Ckey) ? ::Iowa.config[Capplication][Ckey] : C_empty
|
49
|
+
send_data "swiftclient#{Iowa.app.location}#{key.length}#{key}"
|
50
|
+
end
|
51
|
+
|
52
|
+
def deliver_file(filename, suffix, params, headers)
|
53
|
+
if @filecache.include?(filename)
|
54
|
+
d,e,m = @filecache[filename]
|
55
|
+
else
|
56
|
+
d = File.read(filename)
|
57
|
+
e = Digest::SHA256.hexdigest(d)
|
58
|
+
m = File.mtime(filename)
|
59
|
+
@filecache[filename] = [d,e,m] if d.length < 130000
|
60
|
+
end
|
61
|
+
if headers.has_key?(CIF_MODIFIED_SINCE) and Time.parse(headers[CIF_MODIFIED_SINCE]) >= m
|
62
|
+
send_data "HTTP/1.1 304 Not Modified\r\n\r\n"
|
63
|
+
Iowa::Log.info("static #{filename}: 304")
|
64
|
+
else
|
65
|
+
ct = MIME::Types.type_for("foo.#{suffix}").first
|
66
|
+
h = "Connection: close\r\nDate: #{Time.now.httpdate}\r\nLast-Modified: #{m.httpdate}\r\nETag: #{e}\r\nCache-Control: max-age=3600\r\nContent-Type: #{ct ? ct.content_type : 'application/octet-stream'}\r\nContent-Length: #{d.length}\r\n\r\n"
|
67
|
+
send_data "HTTP/1.1 200 OK\r\n"
|
68
|
+
send_data h
|
69
|
+
send_data d
|
70
|
+
Iowa::Log.info("static #{filename}: 200")
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def handle_file(params,headers)
|
75
|
+
path_info = params[CREQUEST_URI]
|
76
|
+
qs = params[CQUERY_STRING]
|
77
|
+
if path_info == C_slash or path_info == C_empty
|
78
|
+
path_info = C_slashindex_html
|
79
|
+
elsif path_info =~ /^([^.]+)$/
|
80
|
+
path_info = "#{$1}/index.html"
|
81
|
+
end
|
82
|
+
|
83
|
+
qsfilename = "#{Iowa.config[Iowa::Capplication][Iowa::Cdoc_root]}#{path_info}__#{qs}"
|
84
|
+
filename = "#{Iowa.config[Iowa::Capplication][Iowa::Cdoc_root]}#{path_info}"
|
85
|
+
if (FileTest.exist?(filename) and File.expand_path(filename).index(Iowa.config[Iowa::Capplication][Iowa::Cdoc_root]) == 0)
|
86
|
+
suffix = path_info.sub(/[_\s]*$/,C_empty)
|
87
|
+
deliver_file(filename, File.extname(suffix)[1..-1],params,headers)
|
88
|
+
true
|
89
|
+
elsif qs and (FileTest.exist?(qsfilename) and File.expand_path(qsfilename).index(Iowa.config[Iowa::Capplication][Iowa::Cdoc_root]) == 0)
|
90
|
+
suffix = path_info.sub(/[_\s]*$/,C_empty)
|
91
|
+
deliver_file(qsfilename, File.extname(suffix)[1..-1],params,headers)
|
92
|
+
true
|
93
|
+
else
|
94
|
+
false
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def post_init
|
99
|
+
@parser = Iowa::HttpParser.new
|
100
|
+
@headers = @params = {}
|
101
|
+
@nparsed = 0
|
102
|
+
@request = nil
|
103
|
+
@request_len = nil
|
104
|
+
@linebuffer = ''
|
105
|
+
end
|
106
|
+
|
107
|
+
def unbind
|
108
|
+
if @completed
|
109
|
+
self.class.connect
|
110
|
+
else
|
111
|
+
Logger['iowa_log'].error "FAILED to connect to cluster server #{self.class.hostname}:#{self.class.port}"
|
112
|
+
::EventMachine.add_timer(rand(4)) {self.class.connect}
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
def process_http_request(headers,params,buffer)
|
117
|
+
unless handle_file(params,headers)
|
118
|
+
clen = buffer.length - headers[CHTTP_CONTENT_LENGTH].to_i
|
119
|
+
body = buffer[clen,headers[CHTTP_CONTENT_LENGTH].to_i]
|
120
|
+
request = Iowa::Request::EMHybrid.new(headers,params,body)
|
121
|
+
response = Iowa.handleConnection request
|
122
|
+
|
123
|
+
@iowa_client.reset(request,response)
|
124
|
+
send_data "HTTP/1.1 #{response.status_line}\r\n"
|
125
|
+
@iowa_client.print(self)
|
126
|
+
end
|
127
|
+
post_init
|
128
|
+
end
|
129
|
+
|
130
|
+
def print(data)
|
131
|
+
send_data data
|
132
|
+
end
|
133
|
+
|
134
|
+
def receive_data data
|
135
|
+
@linebuffer << data
|
136
|
+
@nparsed = @parser.execute(@headers, @linebuffer, @nparsed) unless @parser.finished?
|
137
|
+
if @parser.finished?
|
138
|
+
if @request_len.nil?
|
139
|
+
@request_len = @nparsed + @headers[CHTTP_CONTENT_LENGTH].to_i
|
140
|
+
if @request_len > MAX_BODY
|
141
|
+
new_buffer = Tempfile.new(CEMHYBRIDCLUSTERSERVER)
|
142
|
+
new_buffer.binmode
|
143
|
+
new_buffer << @linebuffer
|
144
|
+
@linebuffer = new_buffer
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
if @linebuffer.length >= @request_len
|
149
|
+
process_http_request(@headers,@params,@linebuffer)
|
150
|
+
end
|
151
|
+
elsif @linebuffer.length > MAX_HEADER
|
152
|
+
raise MaxHeaderExceeded
|
153
|
+
end
|
154
|
+
rescue => e
|
155
|
+
Logger['iowa_log'].error "Error while reading request: #{e}\n#{e.backtrace.join("\n")}"
|
156
|
+
close_connection
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
module Iowa
|
162
|
+
|
163
|
+
# Handle the communications coming in on the monitored socket,
|
164
|
+
# create a context object from the data received, and then pass
|
165
|
+
# the context information into the Application object for final
|
166
|
+
# handling. Exception handling is simply via capturing the Exception
|
167
|
+
# and outputting a stack backtrace (this could be improved).
|
168
|
+
|
169
|
+
class << self
|
170
|
+
remove_method(:handleConnection)
|
171
|
+
remove_method(:eventLoop)
|
172
|
+
remove_method(:run)
|
173
|
+
end
|
174
|
+
|
175
|
+
def self.handleConnection(request)
|
176
|
+
start_time = read_time = Time.now
|
177
|
+
mylog = Logger[Ciowa_log]
|
178
|
+
|
179
|
+
status = []
|
180
|
+
response = handleRequest(request)
|
181
|
+
begin
|
182
|
+
response.status_line = request.status_line if request.status_line
|
183
|
+
response.content_type = request.content_type if request.content_type
|
184
|
+
status[0] = response.status_line
|
185
|
+
if request.headers_out.respond_to?(:length) and request.headers_out.length > 0
|
186
|
+
request.headers_out.each {|k,v| response.headers.set(k,v)}
|
187
|
+
end
|
188
|
+
rescue Exception => e
|
189
|
+
mylog.info e.to_s, e.backtrace.inspect
|
190
|
+
end
|
191
|
+
|
192
|
+
end_time = Time.now
|
193
|
+
logline = "#{start_time} (#{read_time - start_time}/#{end_time - start_time}) :: #{request.uri} \"#{status[0]}\" #{response.body.length}B"
|
194
|
+
mylog.info logline
|
195
|
+
response
|
196
|
+
end
|
197
|
+
|
198
|
+
# Outputs the location of the socket being monitored, then enters the
|
199
|
+
# event loop to wait for and handle connections.
|
200
|
+
|
201
|
+
def self.eventLoop
|
202
|
+
Logger[Ciowa_log].info 'Entering the EMHybrid event loop...'
|
203
|
+
|
204
|
+
::EventMachine.run do
|
205
|
+
#::EventMachine.start_server @config[Csocket][Chostname], @config[Csocket][Cport], EMHybridClusterServer
|
206
|
+
|
207
|
+
EMHybridClusterServer.connect(@config[Csocket][Chostname], @config[Csocket][Cport])
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
def self.run(*args)
|
212
|
+
run_check_started(*args)
|
213
|
+
mylog = Logger[Ciowa_log]
|
214
|
+
my_ip = @config[Csocket][Chostname]
|
215
|
+
my_ip_hex = my_ip.split('.',4).collect {|x| to_hex(x)}.join
|
216
|
+
|
217
|
+
Iowa.app.location = "#{my_ip_hex}#{sprintf('%04s',$$.to_s(16)).gsub(' ','0')}"
|
218
|
+
|
219
|
+
app.initialLoad()
|
220
|
+
@server = nil
|
221
|
+
setup_signal_handlers
|
222
|
+
|
223
|
+
begin
|
224
|
+
eventLoop
|
225
|
+
rescue Exception => exception
|
226
|
+
mylog.fatal "Catastrophic failure in main event loop: #{exception} :: " + exception.backtrace.join(".....").to_s
|
227
|
+
ensure
|
228
|
+
File.delete(@config[Csocket][Cpath]) if @config[Csocket].has_key? Cpath
|
229
|
+
end
|
230
|
+
end
|
231
|
+
end
|