minimal-http-ruby 0.0.9 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/minimal-http-ruby.rb +17 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe16f76d580d9bff3e82b1ac503a37644144f509
|
4
|
+
data.tar.gz: 65d05b793d48dc0fc8b054ac98d5f11357385c20
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a16194c52214a15b2a11003ef9bfbf5abba7f3d251d9a965f3fde5eea32ba9c806aa9a23175240984b43638847c5ac77c78dbd75fdb3fea9e311ce5d874aaf74
|
7
|
+
data.tar.gz: 846b5f85c71792c637f63302640cd39aa4f2bcfc6f77e0fecaa79460898f217dd545fdc1960426a843edb84bafe8ff3dfbe58e0f2cc81c6f4a2d40e0eb25b585
|
data/lib/minimal-http-ruby.rb
CHANGED
@@ -10,7 +10,8 @@ require 'uri'
|
|
10
10
|
require 'ipaddr'
|
11
11
|
require 'time'
|
12
12
|
require 'thread'
|
13
|
-
|
13
|
+
require 'mimemagic'
|
14
|
+
require "fcntl"
|
14
15
|
|
15
16
|
|
16
17
|
def minimal_http_server options={}
|
@@ -53,11 +54,24 @@ def minimal_http_server options={}
|
|
53
54
|
end
|
54
55
|
raw=raw.chop
|
55
56
|
method,req,http_proto = raw.split " "
|
57
|
+
puts "method:#{method}"
|
58
|
+
pp req
|
56
59
|
status="200"
|
57
60
|
type="text/html"
|
58
61
|
req="/#{http_app||'index'}.html" if req=="/" or req=="/index.htm" or req=="/index.html"
|
59
|
-
req,argss=req.split "\?"
|
60
62
|
args={}
|
63
|
+
argss=nil
|
64
|
+
if method=="GET"
|
65
|
+
req,argss=req.split "\?"
|
66
|
+
else
|
67
|
+
len=0
|
68
|
+
while line = client.gets
|
69
|
+
puts "POST>#{line}"
|
70
|
+
len=$1.to_i if line[/Content-Length: (\d+)/]
|
71
|
+
break if line=="\r\n"
|
72
|
+
end
|
73
|
+
argss=client.readpartial(len)
|
74
|
+
end
|
61
75
|
if argss
|
62
76
|
argss.split("&").each do |a|
|
63
77
|
if a
|
@@ -114,7 +128,7 @@ def minimal_http_server options={}
|
|
114
128
|
response=response.to_json
|
115
129
|
end
|
116
130
|
elsif File.file?(fnc="#{$http_dir}#{req}")
|
117
|
-
type=
|
131
|
+
type=MimeMagic.by_path(req)
|
118
132
|
t=File.mtime(fnc)
|
119
133
|
if not prev_t[fnc] or prev_t[fnc]<t
|
120
134
|
contents = File.read(fnc)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minimal-http-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ari Siitonen
|
@@ -50,7 +50,7 @@ dependencies:
|
|
50
50
|
- - ">="
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: 2.3.0
|
53
|
-
description: 'Minimal Http Server
|
53
|
+
description: 'Minimal Http Threaded Server with Ryby: Haml, Coffeescript, SSE, AJAX
|
54
54
|
-- well under 200 lines of code!'
|
55
55
|
email: jalopuuverstas@gmail.com
|
56
56
|
executables:
|
@@ -91,5 +91,5 @@ rubyforge_project:
|
|
91
91
|
rubygems_version: 2.2.2
|
92
92
|
signing_key:
|
93
93
|
specification_version: 4
|
94
|
-
summary: Minimal Http Server Coffeescript,Ajax,Haml,SSE
|
94
|
+
summary: Minimal Http Threaded Server Coffeescript,Ajax,Haml,SSE
|
95
95
|
test_files: []
|