is there any something wrong with dynamic hash definition ?, why the response print doesnt give me the output, but when i give a comment to the first line, the response print sending a output
res.headers.each { |k, v| context.response.headers[k] = v }
context.response.print res.body
my full code : https://github.com/codenoid/lemmehand/blob/master/server.cr thanks ^^
What are you want to do? You got compressed stream that automatically decompressed and send it as is without updating of encoding headers.
minimal working example:
server = HTTP::Server.new(port.to_i) do |context|
params = {} of String => String
context.request.query_params.each do |k, v|
params[k] = v
end
if params.has_key?("get")
HTTP::Client.get(params["get"]) do |res|
context.response.content_type = res.content_type.to_s
context.response.status_code = res.status_code
res.headers.each do |k, v|
next if k == "Content-Encoding"
next if k == "Content-Length"
next if k == "Transfer-Encoding"
context.response.headers[k] = v
end
context.response.print res.body_io.gets_to_end
end
else
context.response.content_type = "text/plain"
context.response.print "you must use GET method,ex. yourserver.com/?get=http://yoururl.com/"
end
end