servit 0.0.3 → 0.0.5

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/servit.rb +17 -17
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 20ee4f2c7b099b37881a2665cec5580a9dfcce2d
4
- data.tar.gz: 647bbcb42ad560c8ab4572831bc1ceb96f4f1f6c
3
+ metadata.gz: a9a3945f4e62d5000aa2bd5056764fc591198275
4
+ data.tar.gz: 9bd648ab83ac5df367d16a147971eb9d228169a9
5
5
  SHA512:
6
- metadata.gz: 082118fbcbda5d308f4e11669402bd534121ebdd9bca0f148a5ce423eeba282ad3b0e5ddc238b5dfe524df1cfc21baabd0ea1f979befb46ab6ae929f7c1cf839
7
- data.tar.gz: 73f625f161883592b4b6994d565151c7c1e293f28c7d98ceebdf21f6bc02e5c875a7fd88524003ad20ea39e236ef3a667c5be947998833307ac83d7575f4ee57
6
+ metadata.gz: 4bb111e5a461558f1258e15f322324f592d808e8e09ad68ba3f05c518fff1f6e17d16443597032e7e7fafe879db8940c7a1c1282513c9441cc9ff1c002bf83cb
7
+ data.tar.gz: 343477a5c4819c3fd26ccbed6ed984c511d4c243d20ec032b03d696e60938ce112078042fc4bb4a6e330fca77b97e5e83323470bab32303528904bc79c5e4e33
@@ -45,29 +45,29 @@ loop do
45
45
 
46
46
  path = File.join(path, 'index.html') if File.directory?(path)
47
47
 
48
- if File.exist?(path) && !File.directory?(path)
49
- File.open(path, "rb") do |file|
50
- socket.print "HTTP/1.1 200 OK\r\n" +
51
- "Content-Type: #{content_type(file)}\r\n" +
48
+ if File.exist?(path) && !File.directory?(path)
49
+ File.open(path, "rb") do |file|
50
+ socket.print "HTTP/1.1 200 OK\r\n" +
51
+ "Content-Type: #{content_type(file)}\r\n" +
52
+ "Content-Length: #{file.size}\r\n" +
53
+ "Connection: close\r\n"
54
+
55
+ socket.print "\r\n"
56
+
57
+ IO.copy_stream(file, socket)
58
+ end
59
+ else
60
+ File.open("404.html") do |file|
61
+
62
+ socket.print "HTTP/1.1 404 Not Found\r\n" +
63
+ "Content-Type: text/html\r\n" +
52
64
  "Content-Length: #{file.size}\r\n" +
53
65
  "Connection: close\r\n"
54
66
 
55
67
  socket.print "\r\n"
56
-
57
68
  IO.copy_stream(file, socket)
58
69
  end
59
- else
60
- message = "File not found\n"
61
-
62
- socket.print "HTTP/1.1 404 Not Found\r\n" +
63
- "Content-Type: text/plain\r\n" +
64
- "Content-Length: #{message.size}\r\n" +
65
- "Connection: close\r\n"
66
70
 
67
- socket.print "\r\n"
68
-
69
- socket.print message
71
+ socket.close
70
72
  end
71
-
72
- socket.close
73
73
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: servit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Elliott