mirror of
https://github.com/balkian/SWCM.git
synced 2024-11-22 20:52:29 +00:00
UTF-8 and minor fixes
This commit is contained in:
parent
4e80e6330e
commit
ad3297b84b
@ -3,7 +3,7 @@ require 'socket'
|
|||||||
numCon = 0
|
numCon = 0
|
||||||
maxCon = 10
|
maxCon = 10
|
||||||
|
|
||||||
def respond(socket, code, body) # Genera prespuestas
|
def respond(socket, code, body) # Genera respuestas
|
||||||
socket.puts "HTTP/1.0 #{ code }"
|
socket.puts "HTTP/1.0 #{ code }"
|
||||||
socket.puts "Content-type: text/html"
|
socket.puts "Content-type: text/html"
|
||||||
socket.puts "Content-length: #{ body.length }"
|
socket.puts "Content-length: #{ body.length }"
|
||||||
@ -15,12 +15,12 @@ end
|
|||||||
server = TCPServer.open(8080)
|
server = TCPServer.open(8080)
|
||||||
puts "web server created at port 8080"
|
puts "web server created at port 8080"
|
||||||
loop do
|
loop do
|
||||||
if(numCon < maxCon)
|
if(numCon < maxCon) # Si no se ha superado el número máximo de hebras
|
||||||
sock = server.accept # Acepta conexión del cliente
|
sock = server.accept # Acepta conexión del cliente
|
||||||
t = Thread.new(sock) do |socket|
|
t = Thread.new(sock) do |socket|
|
||||||
numCon=numCon+1
|
numCon=numCon+1
|
||||||
request = socket.gets # Lee la primera línea
|
request = socket.gets # Lee la primera línea
|
||||||
o = socket.gets until ( o != "") # cabecera acaba con línea vacía
|
o = socket.gets until ( o != "") # cabecera acaba con línea vacía
|
||||||
|
|
||||||
unless request =~ /^GET/ # Si el comando no esta soportado
|
unless request =~ /^GET/ # Si el comando no esta soportado
|
||||||
respond socket, "400 Bad Request", "<html><body><h1>Comando desconocido</h1></body></html>"
|
respond socket, "400 Bad Request", "<html><body><h1>Comando desconocido</h1></body></html>"
|
||||||
|
Loading…
Reference in New Issue
Block a user