about summary refs log tree commit homepage
path: root/test/test_http11.rb
diff options
context:
space:
mode:
authorzedshaw <zedshaw@19e92222-5c0b-0410-8929-a290d50e31e9>2006-01-28 19:03:53 +0000
committerzedshaw <zedshaw@19e92222-5c0b-0410-8929-a290d50e31e9>2006-01-28 19:03:53 +0000
commit004dec2c2f44a0db510dfd65e5ffd8c9fc4ff83e (patch)
treea8b7de6debeb447af5479bf156706d09fe748ab4 /test/test_http11.rb
parentb6d34b2a4191a3118c7c70ea49349e89e581ed91 (diff)
downloadunicorn-004dec2c2f44a0db510dfd65e5ffd8c9fc4ff83e.tar.gz
git-svn-id: svn+ssh://rubyforge.org/var/svn/mongrel/trunk@4 19e92222-5c0b-0410-8929-a290d50e31e9
Diffstat (limited to 'test/test_http11.rb')
-rw-r--r--test/test_http11.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/test_http11.rb b/test/test_http11.rb
new file mode 100644
index 0000000..8f07900
--- /dev/null
+++ b/test/test_http11.rb
@@ -0,0 +1,31 @@
+require 'test/unit'
+require 'http11'
+
+
+class HttpParserTest < Test::Unit::TestCase
+    
+    def test_parse_simple
+            parser = HttpParser.new
+            req = {}
+            http = "GET / HTTP/1.1\r\n\r\n"
+            nread = parser.execute(req, http);
+            assert nread == http.length, "Failed to parse the full HTTP request"
+            assert parser.finished?, "Parser didn't finish"
+            assert !parser.error?, "Parser had error"
+            assert nread == parser.nread, "Number read returned from execute does not match"
+            parser.reset
+            assert parser.nread == 0, "Number read after reset should be 0"
+    end
+    
+    
+    def test_parse_error
+        parser = HttpParser.new
+        req = {}
+        bad_http = "GET / SsUTF/1.1"
+        nread = parser.execute(req, bad_http)
+        assert nread < bad_http.length, "Number read should be less than total on error"
+        assert !parser.finished?, "Parser shouldn't be finished"
+        assert parser.error?, "Parser SHOULD have error"
+    end
+end
+