Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
mattn committed May 7, 2014
1 parent d6a2bfa commit 31e09e2
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions example/server.rb
Expand Up @@ -5,17 +5,16 @@
return if x != 0
c = s.accept()
c.read_start do |b|
if b
r = h.parse_request(b)
body = "hello #{r.path}"
if !r.headers.has_key?('Connection') || r.headers['Connection'] != 'Keep-Alive'
c.write("HTTP/1.1 200 OK\r\nConnection: close\r\nContent-Length: #{body.size}\r\n\r\n#{body}") do |x|
c.close() if c
c = nil
end
else
c.write("HTTP/1.1 200 OK\r\nConnection: keep-alive\r\nContent-Length: #{body.size}\r\n\r\n#{body}")
next unless b
r = h.parse_request(b)
body = "hello #{r.path}"
if !r.headers.has_key?('Connection') || r.headers['Connection'] != 'Keep-Alive'
c.write("HTTP/1.1 200 OK\r\nConnection: close\r\nContent-Length: #{body.size}\r\n\r\n#{body}") do |x|
c.close() if c
c = nil
end
else
c.write("HTTP/1.1 200 OK\r\nConnection: keep-alive\r\nContent-Length: #{body.size}\r\n\r\n#{body}")
end
end
end
Expand Down

0 comments on commit 31e09e2

Please sign in to comment.