255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
|
# File 'lib/gopher.rb', line 255
def receive_data(data)
begin
raise InvalidRequest if data.length > 255
response = app.request(data)
case response
when String then send_data(response)
when StringIO then send_data(response.read)
when File
while chunk = response.read(8192) do
send_data(chunk)
end
end
close_connection_after_writing
rescue Gopher::NotFound
send_data "not found"
close_connection_after_writing
rescue => e
close_connection
raise e
end
end
|