什麼是你想做什麼?你得到了壓縮的流,自動解壓縮併發送它,而不需要更新編碼頭。
最小工作例如:
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